Hello together,
I have checked the forum but did not find any case fitting my one.
I would like to assign an IP-address to a device PC1 on port "ether4" depending on the device connected to port "ether5" (PC2 or PC3). I wrote a script but it does not work (RouterOS 7.13.3):
:local macaddress5 [[:pick [/interface ethernet find where name="ether5"] 1 18]]
:local ipaddress
:log info ("MAC Address on ether5: " . $macaddress5)
:if ($macaddress5 = "MAC-OF_PC2") do={
:set ipaddress "10.150.2.1"
:log info ("Setting IP Address to: " . $ipaddress)
} else={
:if ($macaddress5 = "MAC-OF_PC3") do={
:set ipaddress "192.168.11.234"
:log info ("Setting IP Address to: " . $ipaddress)
} else={
:set ipaddress "192.168.88.130"
:log info ("Setting IP Address to: " . $ipaddress)
}
}
/ip dhcp-server lease set [find where mac-address="MAC-OF-PC1"] address=$ipaddress
The script is neither able to get the MAC-address of the device connected to port "ether5" ($macaddress5 is empty), nor assigns the (default) IP-address "192.168.88.130" to PC1 on "ether4".
PC1 = notebook, PC2 and PC3 = embedded hardware. Notebook and embedded HW communicate via SW simulator/webbrowser, which is why a certain IP-address of PC1 is needed....
Thanks!