Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Does Linux have native support for load balanced (maybe as simple as RR or IP Hash) multiple default gateways?

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

It's been a little spotty in the past, but any modern distribution should have that capability. First verify that the kernel has been built with these two settings.

CONFIG_IP_MULTIPLE_TABLES=y
CONFIG_IP_ROUTE_MULTIPATH=y

You'll also need to install iproute, which is sometimes iproute2 again depending on the distribution. FWIW a default install of 10.04 LTS should have all this ready to go.

Docs and code

share|improve this answer
    
Any idea how the load balancing happens with this? Random or round robin per packet? (Per packet will be fine, no state-fullness on the gateways so asymmetry will not be an issue) –  Kyle Brandt Mar 22 '12 at 18:36
    
I believe it'll be per connection or tcp stream. Per packet works well over multiple connections to one device rather than multiple devices though I'm a bit out of date on deep networking. If you have large rsyncs, db backups, or other connections you're worried might swamp one of the interfaces you can look at some qos, perhaps SFQ. Some basic explanation here. sean.psycris.net/?p=144 –  kashani Mar 22 '12 at 20:16
    
To enable per packet load balancing you should have CONFIG_IP_ROUTE_MULTIPATH=y set, then you will need to add your route with iproute2 using the equalize option. See tipsternet.com/articles/advance%20routing.htm (there are some more complex options here too, but if you want to equalize everything I don't believe you'll need to use firewall tagging, just add the route with equalize and two next hops) –  johnf Mar 23 '12 at 0:29
add comment

Your kernel has to be compiled with CONFIG_IP_ROUTE_MULTIPATH enabled and then you can create multiple equal routes or use a dynamic routing protocol that supports load balancing. Take a look here and here for more information. For reference my generic install of CentOS 5.5 does have CONFIG_IP_ROUTE_MULTIPATH enabled.

share|improve this answer
add comment

Multiple default gateways is rarely going to have the desired affect. If one of the gateways is down you're going to lose the traffic that is sent to it.

What are you trying to achieve by using more than one gateway? Dynamic routing, 802.3ad link aggregation (LaCP) or a combination of the two is probably closer to the solution you are looking for.

share|improve this answer
    
The gateways will be MHSRP, so if one goes down, the other router will hold both VIPs which solves for the issue you mentioned. –  Kyle Brandt Mar 22 '12 at 18:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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