:global newIP 1.1.1.1
:foreach i in=[/ip firewall nat find comment=TEST] do={
/ip firewall nat set $i to-addresses=$newIP
}
I am having setup that some mikrotik routers get IP of another router and use it with some firewall rules, but problem is where IP has changed and i must mannualy go to every router and change IP like in the script above.
Its not possible to use ddns name from ip-cloud, so there is another thing i can do? I am having dyndns account and i tried something like this, but its a raw code, never worked ![]()
:global newIP
:global ddnsServer dyn.com
:global hostname myhostname
:global username myusername
:global password mypassword
:log info "Getting current IP from $ddnsServer"
/tool fetch url="http://members.dyndns.org/nic/update?hostname=$hostname" user=$username password=$password
:set newIP [/tool fetch get value]
:log info "New IP is $newIP"
:foreach i in=[/ip firewall nat find comment=TEST] do={
/ip firewall nat set $i to-addresses=$newIP
}