Hello,
I would like to know if it possible to replace recursive routing with netwatch or a script ?
I already tried this in the past but without success.
I have 2 WAN connections in failover mode and use recursive routing to monitor main WAN.
It works as expected but it is a little bit complicated (3 nested recursive IP).
I can’t use check-gateway on my ISP first gateway because it refuses to answer to ping…
With my previous linux router I used to have a small script which constantly (each 20s) simply ping 2 or 3 different IPs.
To manage to do this properly, I have this (simplified) main routing table :
default via x.x.x.x dev wan1 metric 1
default via y.y.y.y dev wan2 metric 100
default via x.x.x.x dev wan1 metric 2000
default via y.y.y.y dev wan2 metric 2100
Note the two routes for each interface. The first route with the lower metric will be removed / disabled if the wan interface failed.
For example, if wan1 failed, the default route with metric 1 will be disabled. Automatically, the next default route (wan2 with metric 100 here) will take the traffic. As soon as the wan1 came back, its default route with metric 1 will be restored.
of course, I have associated the right routing rules and routing table for each interface/gateway…
Here is the HIGHLY simplified algorithm (note the from-interface param on ping command) :
function disable() {
if default route interface=wan1 table=main metric=1 enabled ; then
disable default route table=main metric=1
fi
}
function enable() {
if default route interface=wan1 table=main metric=1 disabled ; then
enable default route table=main metric=1
fi
}
if ping ip1 from-interface=wan1 failed ; then
if ping ip2 from-interface=wan1 failed ; then
if ping ip3 from-interface=wan1 failed ; then
function disable
else
function enable
fi
else
function enable
fi
else
function enable
fi
I would like to use this little script (no issue for me to use ROS script language) associated to netwatch in the ‘On Test’ section.
I know it is NOT possible to define output interface for ping in netwatch. This is why I would like to use this script and ROS ping command to force output interface to test.
Do you already managed to monitor interface and do failover with netwatch or simple script like this ?
thanks.
