Take a look at this advanced routing <a href=”http://tldp.org/HOWTO/Adv-Routing-HOWTO/”>How-To</a>. Consider chapters 3 & 4.
Basically, you need to add rules to state that what comes in an interface also goes back out the same one…
And if you are NATting ok, the reverse is always true…
The HOWTO also explains how to do a basic load balance using the ‘weight’ keyword, but there doesn’t appear to be another ‘ip route’ option. Of course you can use the iptables mangle table to mark the outgoing packets and ‘ip rule’ against that mark.
So one basic config is as it’s written in the HOWTO, but I have 5 possible outgoing interfaces, 2 under ‘weight’ control and the others under MARK control.
A 3 interface example:
Name the ‘tables’, one for each interface, ds1, dsl2, dsl3 (chapter 4.1 3rd example)
echo 200 dsl1 >> /etc/iproute2/rt_tables
echo 201 dsl2 >> /etc/iproute2/rt_tables
echo 202 dsl3 >> /etc/iproute2/rt_tables
Jump down to chapter 4.2.1 Split access, and make routes in the tables
based on the interfaces & ip numbers & gateways
ip route add dsl1_network dev eth1 src eth1_ip_number table dsl1
ip route add dsl2_network dev eth2 src eth2_ip_number table dsl2
ip route add dsl3_network dev eth3 src eth3_ip_number table dsl3
and gateway routes…
ip route add default via dsl1_ip_number table dsl1
ip route add default via dsl2_ip_number table dsl2
ip route add default via dsl3_ip_number table dsl3
Now the regular routes.. (= table routes minus the tables)
ip route add dsl1_network dev eth1 src eth1_ip_number
ip route add dsl2_network dev eth2 src eth2_ip_number
ip route add dsl3_network dev eth3 src eth3_ip_number
The default routes load balanced (kind of) for outgoing..
ip route add default scope global nexthop via dsl1_ip_number dev eth1 weight 5 nexthop via dsl2_ip_number dev eth2 weight 5 nexthop via dsl3_ip_number dev eth3 weight 5
And finally the rules of who comes from where..
ip rule add from eth1_ip_number table dsl1
ip rule add from eth2_ip_number table dsl2
ip rule add from eth3_ip_number table dsl3
There are usually places in the ifup/down scripts to place config file statements to do all this at boot or net restart. You may have to use replace instead of add to remove old route statements…