Fail over scripting

I kow it has been accomplished by moving gateway metrics, but i am looking for a basic failover method.

I have a main (cable) and a backup (cellular) connection. I am looking to script a ping every 5 seconds or so that looks to the outside world say google, if that fails, it will switch to the backup connection.

The only examples I see ping the gateway, I have tried this but been unsuccessful, perhaps I am doing it wrong.

Hi, i’ve tried two different methods:

  1. By assigning to every interface a route and then routing traffic through it with different metric. That actually works.

  2. By applying VRRP, different solution - equal result.

But the question that seems that no one can answer is: How to do a smart failover checking link quality?

I have a similar issue, i’m having 3 differents WAN but it always chooses that one that have the lowest metric, and can’t choose the one with the best performance.

I mean, if i have 80% loss over number 1 metric - Traffic goes over there anyway.

Thank you for the reply,

I am currently doing mangle fail over but the issue seems to be it will only failover if my modem or gateway is not reachable, I need a script that will ping the outside world. (i.e Google or nist)

Wan1 is a cable modem
Wan2 is a cellular backup.

Most of my outages have been beyond the node gateway of the cable company. because the Mtik can see the cable modem gateway it doesn’t redirect the metric.

If you are able to evaluate the link quality, why not to set the distance metrics according that?

Good point, if you already know who is the main ISP you only have to assign it the lowest metric.

Example:
[admin@Router] > ip route print

DST-ADDRESS PREF-SRC GATEWAY DISTANCE

0 A S 0.0.0.0/0 [IP GW main] 1
1 S 0.0.0.0/0 [IP GW bk ] 2


Then you can do something else, you can set the "check-gateway ping" for both conections.

In your main ISP, i see that you don't have any trouble... you already did it.

But with your secondary (the cell) you should do this:

add dst-address=8.8.8.8 gateway=[IP GW bk ] scope=10
add distance=2 gateway=8.8.8.8 check-gateway=ping

So... when you send any request to 8.8.8.8 it will be always by the GW BK. Then you have to set 8.8.8.8 as a Gateway (to get a reference IP) and you can now set check-gateway=ping

That is a homemade and easy way, but i recommend you to read about vrrp that is what you need to apply in this scenario.

Regards.