netwatch instead of recursive routing

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.

with more recent V7 you can now at least use src-address now for netwatch, i have yet to lab this as well just like you I also use recursive routing for WAN monitoring

Hello,
sorry, but I do not see src-address for netwatch … (ROS 7.10.2)

ok, I saw, it is only on 7.11 (beta).
But even with src-address param, we cannot use multiple ip to check.
If the single defined ip is down, mkt will consider wan interface as down. I prefer to have multiple…

Do a forum search, IM pretty sure I saw at least one thread with a solution…

Thanks.
I would like your opinion about the concept.
Script instead of recursive route.

I am pretty sure that the algo works because i am using it on a pure linux router.
But it could be a bad idea on ROS… and prefer recursive route for some reasons.

Thanks for your comments.