Round Robin Default Gateways on Linux

Solution 1:

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

Solution 2:

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.

Solution 3:

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.