Auto Gateway Change Scripts that work in ROS v7

:if ($bound=1) do={/ip route set [find where dst-address=0.0.0.0/0 routing-table=ISP1 ] gateway=$"gateway-address" }

Hi, This code seems not working ROS v7 but only in v6.xx.
Could you get code that working v7.

This code is ‘Auto Gateway Change Scripts’. I found lately.

http://forum.mikrotik.com/t/completing-a-script-for-checking-and-updating-dynamic-isps-gateway/147715/1
http://forum.mikrotik.com/t/completing-a-script-for-checking-and-updating-dynamic-isps-gateway/147715/1

Maybe there’s something I’m missing or I’m not aware of.
Please, reply.

Appreciated.


CCR2004-16G-2S+PC

ROS v7.3.1

Did you add the route first? This script only updates gateway, doesn’t add route if it doesn’t exist.

Yes, of course. But at DHCP client renew or release seems not updated.
Does code seems working well? I using 2WAN to 2LAN.

Received two ip is applied to my two NAS.
If it working good, seems i misunderstood about this code algorism.

I’ll try again. Thank you.
snap006.jpg

It depends on what exactly you configured. If you have two DHCP clients, you need two routes, one for each, in different routing tables. Each DHCP client needs script with own routing-table=. And if both gateways have same IP address, you also need to append %etherX to gateway addresses in scripts.

I Understand. Thanks…

help
How can I add the %ether1 variable to the gateway in the dhcp client script

{not tested, just for provide a reply}

:if ($bound=1) do={/ip route set [find where dst-address=0.0.0.0/0 and routing-table="ISP1" ] gateway=( $"gateway-address" . "%ether1" ) }

Thanks. I applied the script now. How should I test to see if the script change?
Just renew menu alone cannot confirm. What the comma mean? between address and ether.

%ether1 variable is already added. Thank you!