I have 2 ISPs, and a server with two IP addresses, something like this:


I have set www.example.com with two A records, so that I have DNS LB.

App is working fine this way, and Linux box is set with policy based routing to avoid asymmetric routing of connections. Outgoing packets leave through same interface incoming connections were established through.

Now, only problem left is that I have set a single default gateway, I would like to achieve either LB or at least failover for outgoing connections too.

One way I could do it is with cronjob that will ping some host and if ping fails, change the default route to, but this method seems way too unreliable.

Any suggestions on how to failover default route?


If you don't want to get into real routing protocols, the best suggestion is a continuously running program that pings the two first hops (with your made up addresses, that'd be and regularly and installs whichever is responding as the default route. You could probably do this in your choice of scripting languages, although I'd probably do it in C myself. In fact, I have (but no longer can find that code). It's simple enough to get right, and doing it in C greatly lowers the impact on your server.


I have a answer, though you won't like it. Multiple RR A in DNS won't get you high availability. The answer is highly dependent on the client/their DNS server.

If the client solves the IP address of the ISP that is down, it will keep it on cache, and won't try the other, so you will have a set of clients having access, and others complaining the site is down.

Low TTLs also won't help you, as some DNS clients/big ISPs are known for ignoring low TTLs, so even with LOW TTLs in DNS, you will have sets of clients no having access.

One of the possible solutions is enlisting the services of a CND like cloudflare, and configuring there both IP addresses.

The other, more complicated way of getting redundancy for external routes, is requesting an AS number, using provider independent IP address space for both networks, and doing BGP peering with your providers.

As for the route while leaving, to take advantage of traffic of both ISPs, I do advise doing policies to use the corresponding gateway, source based routing. http://www.novell.com/support/kb/doc.php?id=7008874

  • (I could not elaborate more about source based routing as I am travelling today. – Rui F Ribeiro Jul 24 '16 at 19:06
  • BGP is offcourse the best way to go, but it's not possible in this case. I am aware of the best practices so thanks. Regarding DNS RR, it works fine as long as clients are modern internet browsers. They are able to detect one IP is down and after refresh automatically select other one and that is enough for this specific use case. – Jakov Sosic Jul 25 '16 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.