IP load balancing
From FlimzyWiki
To my surprise, this was pretty straight forward. I borrowed the instructions from http://lartc.org/howto/lartc.rpdb.multiple-links.html, and wrote a script that could be added to an appropriate startup script.
I simply created a bash script that looks like this:
#!/bin/bash
P0_NET=172.17.1.0/24
P0_GW=172.17.1.254
P0_IP=172.17.1.222
P0_DEV=eth0
P0_TABLE=4
P1_NET=192.168.50.0/24
P1_GW=192.168.50.254
P1_IP=192.168.50.99
P1_DEV=eth1
P1_TABLE=5
ip route flush table $P0_TABLE
ip route flush table $P1_TABLE
ip route add $P0_NET dev $P0_DEV src $P0_IP table $P0_TABLE
ip route add default via $P0_GW table $P0_TABLE
ip route add $P1_NET dev $P1_DEV src $P1_IP table $P1_TABLE
ip route add default via $P1_GW table $P1_TABLE
ip route add $P0_NET dev $P0_DEV src $P0_IP
ip route add $P1_NET dev $P1_DEV src $P1_IP
ip route add default via $P0_IP
ip rule add from $P0_IP table $P0_TABLE
ip rule add from $P1_IP table $P1_TABLE
ip route del default
ip route add default scope global nexthop via $P0_GW dev $P0_DEV weight 1 \
nexthop via $P1_GW dev $P1_DEV weight 1
It should be possible to add additional interfaces following the pattern above. I intend to add at least one more, possibly two more, interfaces in the future, for a 3- or 4-homed machine.
The machine running with this configuration isn't an actual router in my case, but just a squid proxy. Both interfaces are NAT'ed (as you might guess from the IP ranges in the config file).
In my case, eth0 is plugged into our office LAN, which has two T1's, each from a different provider. I intend t configure eth0 to bind to one of the T1s, and eth0:1 to bind to the second T2, to get a sort of "virtual dual-homed" NIC setup on eth0. eth1 then plugs into a 1.5mbit DSL connection. I may also plug in a WiFi card and bind it to a WiFi network, for a total of 4 Internet connections.

