How to setup a backup internet connection from a second ISP?

Please see the Linux Advanced Routing & Traffic Control documentation for "Routing for multiple uplinks/providers" here:

https://web.archive.org/web/20180304202946/http://lartc.org/howto/lartc.rpdb.multiple-links.html


You may read Gateway status checking methods on linux/bsd it's similar to what you are asking.
To answer you question precisely. You have normally 2 public IP address, one on eth0 and one on eth1.
You could write a script that try to ping the default gateway of isp1 (on eth0) and switch to eth1 if ping fail. But this will only switch when your link at your side is down (like DSL line down) but not from an outage within the ISP network because his gateway will still ping.
So you probably what to :

1.Ping ISP1 default gateway
2. Ping www.google.com or something else that is reliable
3. Check for paquet on eth0 with tcpdump 3.

If 1 is down, you should change the defaut gatway to the ISP2 gatway IP.
If 1 is Ok but 2 is Ko, may be it's juste google, may be an outage on ISP side, you may try other well know service yahoo.com, microsoft.com if all are Ko you probably want to switch to ISP2. You could use 3 here to see if you still receive packet from internet.

Depending on your distribution you have certainly some ifup/ifdown script somewhere in /etc they are called when an interface come up and down. This can also be used to switch the gateway. They will be called only when you lost the ethernet link.


In fact, true internet connection redundancy is only achieved by using BPG as an Autonomous System. This way you may have any number of uplinks from any number of ISPs, which will all point to your IP-address(es), which will be truly yours, not leased or rented, but an subnet you'll be able to use anywhere...

While the topic of acquiring ASN & setting up BGP is out of the scope of original question, I think it's important to mention nevertheless. If you feel interested, here is a guide you can start with:

https://www.auvik.com/media/blog/redundant-internet-connection-bgp/

Tags:

Router

Debian