Hi all,
I work in a project with two private LAN-gateways.
I want to use the netwatch-tool with up and down scripts.
My setup looks like followed:
Script: gw_1
/ip route set [/ip route find dst-address 0.0.0.0] gateway=192.168.10.254
Script: gw_2
/ip route set [/ip route find dst-address 0.0.0.0] gateway=192.168.10.250
Netwatch:
/tool netwatch> add host=8.8.8.8 interval=10s timeout=998ms up-script=gw_2 down-script=gw_1
But my scripts don’t work
I followed this guide: http://www.mikrotik.com/testdocs/ros/2.9/tools/netwatch.php
I think the mistake is the command “/ip route find …” When I try to execute this command manually in a terminal it gives me no return-value.
Maybe someone know where’s my mistake.
P.S.: I am using RouterOS 5.8 on a MikroTik RouterBOARD RB/750.
Thank you in advance!
Regards,
Sp4eTzle
Edit: Marked the topic as solved!
tjc
2
Looks like you’re missing an “=”…
[admin@MikroTik] > :put [/ip route find dst-address 0.0.0.0/0]
[admin@MikroTik] > :put [/ip route find dst-address=0.0.0.0/0]
*30000001
Also note that the bit inside the doesn’t print anything on the console regardless. You have to use :put for that.
Yes that’s right!
But how can I use my commands to change the route? At the moment I use the followed command:
Script: gw_1
[admin@MikroTik] > /ip route set numbers=0 disabled=yes
[admin@MikroTik] > /ip route set numbers=1 disabled=no
Script: gw_2
[admin@MikroTik] > /ip route set numbers=1 disabled=yes
[admin@MikroTik] > /ip route set numbers=0 disabled=no
But this is not the best solution I think, because when someone add a route it could get the number of the default-route. You know what I mean?
Regards.
janisk
4
set up comment to identify the routes. then find them to identify and then apply changes to IDs found.
Thank you so much! That works fine!
Now I use the followed command:
Script: gw_1
[admin@MikroTik] > /ip route set [/ip route find where comment="ISP2"] disabled=yes
[admin@MikroTik] > /ip route set [/ip route find where comment="ISP1"] disabled=no
Script: gw_2
[admin@MikroTik] > /ip route set [/ip route find where comment="ISP2"] disabled=no
[admin@MikroTik] > /ip route set [/ip route find where comment="ISP1"] disabled=yes
And the scripts in netwatch… it works great! Thanks a lot!
Regards