LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Two gateways on eth0 how to do this (http://www.linuxquestions.org/questions/linux-networking-3/two-gateways-on-eth0-how-to-do-this-4175425429/)

MarcusWebb1966 09-03-2012 11:20 AM

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.

Scenario:
=========
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

Code:

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.
Marcus

MensaWater 09-03-2012 01:25 PM

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.

Celyr 09-03-2012 01:39 PM

i would suggest you to do:

Code:

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

MarcusWebb1966 09-07-2012 07:55 AM

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.


All times are GMT -5. The time now is 11:29 PM.