6

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

3 Answers 3

6

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

3
  • 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) Mar 22, 2012 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, 2012 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, 2012 at 0:29
2

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.

1
  • The gateways will be MHSRP, so if one goes down, the other router will hold both VIPs which solves for the issue you mentioned. Mar 22, 2012 at 18:35
1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .