Community discussions

MikroTik App
 
aliaskorea
newbie
Topic Author
Posts: 27
Joined: Tue Jul 31, 2018 9:07 am

Auto Gateway Change Scripts that work in ROS v7

Sat Jun 11, 2022 7:12 pm

: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.

viewtopic.php?t=173560
viewtopic.php?t=173560#p929446

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

Appreciated.


CCR2004-16G-2S+PC

ROS v7.3.1
 
Sob
Forum Guru
Forum Guru
Posts: 9119
Joined: Mon Apr 20, 2009 9:11 pm

Re: Auto Gateway Change Scripts that work in ROS v7

Sat Jun 11, 2022 7:40 pm

Did you add the route first? This script only updates gateway, doesn't add route if it doesn't exist.
 
aliaskorea
newbie
Topic Author
Posts: 27
Joined: Tue Jul 31, 2018 9:07 am

Re: Auto Gateway Change Scripts that work in ROS v7

Sat Jun 11, 2022 8:42 pm

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.
You do not have the required permissions to view the files attached to this post.
 
Sob
Forum Guru
Forum Guru
Posts: 9119
Joined: Mon Apr 20, 2009 9:11 pm

Re: Auto Gateway Change Scripts that work in ROS v7

Sat Jun 11, 2022 9:31 pm

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=<name>. And if both gateways have same IP address, you also need to append %etherX to gateway addresses in scripts.
 
aliaskorea
newbie
Topic Author
Posts: 27
Joined: Tue Jul 31, 2018 9:07 am

Re: Auto Gateway Change Scripts that work in ROS v7

Sun Jun 12, 2022 2:33 pm

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=<name>. And if both gateways have same IP address, you also need to append %etherX to gateway addresses in scripts.
I Understand. Thanks...
 
hermestcp
just joined
Posts: 1
Joined: Tue Jun 14, 2022 3:11 am

Re: Auto Gateway Change Scripts that work in ROS v7

Tue Jun 14, 2022 3:24 am

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.
help
How can I add the %ether1 variable to the gateway in the dhcp client script
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Auto Gateway Change Scripts that work in ROS v7  [SOLVED]

Tue Jun 14, 2022 10:09 am

{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" ) }
 
aliaskorea
newbie
Topic Author
Posts: 27
Joined: Tue Jul 31, 2018 9:07 am

Re: Auto Gateway Change Scripts that work in ROS v7

Thu Jun 16, 2022 3:07 pm

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.
 
aliaskorea
newbie
Topic Author
Posts: 27
Joined: Tue Jul 31, 2018 9:07 am

Re: Auto Gateway Change Scripts that work in ROS v7

Thu Jun 16, 2022 3:08 pm



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.
help
How can I add the %ether1 variable to the gateway in the dhcp client script
%ether1 variable is already added. Thank you!

Who is online

Users browsing this forum: No registered users and 15 guests