Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 09-03-2012, 10:20 AM   #1
Registered: Mar 2011
Posts: 58

Rep: Reputation: 0
Two gateways on eth0 how to do this

Ok, so the similar threads didn't really help me on this one, so once again Dear LQ Users, I'm asking for your advice on this matter.

We've got some servers in a datacentre. These are behind a firewall. They are happy. There are no problems.

We now have a load balancer for certain servers. This is requesting that it is the gateway. This is fine for everything that addresses the servers via the load balancers but in the event that the load balancer fails or becomes decommissioned for any particular reason, then we need to be able to automatically route via the firewall.

Is it therefore possible to have something that says

route_eth0="default via 10.x.x.80 alternate via 10.x.x.4"
or similar? I'm guessing that you need to use metrics here to weight the direction the traffic takes. Bear in mind that all these servers have only ONE ethernet card. Anything else you need to know, please do ask.

Thanks in Advance for any/all assistance rendered.
Old 09-03-2012, 12:25 PM   #2
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,412
Blog Entries: 15

Rep: Reputation: 1427Reputation: 1427Reputation: 1427Reputation: 1427Reputation: 1427Reputation: 1427Reputation: 1427Reputation: 1427Reputation: 1427Reputation: 1427
I don't think so and I don't see how it would work anyway at host level. Typically if you're on a load balancer the reason they want the gatweway changed is because you're directly connected (or switched) to the load balancer. Which is to say if the load balancer is down your traffic is going to fail as you've already surmised because it has no other route. To route around the load balancer would be a switch change (or physical connection change if direct connected) rather than a host level change.

What we do instead is we keep two separate NICs at host level. One routes through the load balancer and the other routes through our normal "internal" network. Even when we have internal facing load balancers we do this.
1 members found this post helpful.
Old 09-03-2012, 12:39 PM   #3
Registered: Mar 2012
Location: Italy
Distribution: Slackware+Debian
Posts: 321

Rep: Reputation: 81
i would suggest you to do:

 sleep 1
 if (default gateway is reachable) and not (on backup)
   do nothing
 if (default gateway is not reachable) and not (on backup)
   change route to backup gw
 if (default gateway is reachable) and (on backup)
   change route to default gw
 if (default gateway is not reachable) and not (on backup)
   do nothing

while true
It may look a bit quirky but i think it's the easiest solution
Old 09-07-2012, 06:55 AM   #4
Registered: Mar 2011
Posts: 58

Original Poster
Rep: Reputation: 0
Just to let you know:

Whilst Celyr's method would work in principle, I've come round to MensaWater's way of thinking, and cannot see a benefit to providing multiple gateways.

Thanks to all who read and all you who answered so thoughtfully.


eth0, gateways, networking

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
vnStat - if pointed to eth0 will it aggregate eth0 and eth0:1 alias stardotstar Linux - Networking 0 07-20-2010 07:49 PM
Two gateways? candyman123 Linux - Networking 1 09-08-2005 12:36 PM
Gateways Esmo2000 Linux - Networking 1 01-03-2005 02:49 PM
2 Gateways Equis Linux - Networking 1 11-15-2003 03:58 AM
2 Gateways def1014 Linux - Networking 3 10-24-2002 05:21 PM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:23 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration