Routing for multiple uplinks
The goal of this article is to show an easy way allowing to use two uplinks on a Linux gateway.
As requirement, you need the package "iproute" installed.
The first step is to create the "iproute" tables relative to the two uplinks mentionned above, via "/etc/iproute2/rt_tables":
200 uplink_isp1
201 uplink_isp2
The second one is to perform the network settings. Here is a sample "/etc/network/interfaces" file (Debian) for two ISP:
# ISP1
auto eth0
iface eth0 inet static
address 10.10.1.253
netmask 255.255.255.0post-up ip route add 10.10.1.254/32 dev eth0 src 10.10.1.253 table uplink_isp1
post-up ip route add default via 10.10.1.254 table uplink_isp1
post-up ip rule add from 10.10.1.253 table uplink_isp1post-up ip route del 10.10.1.254/32 dev eth0 src 10.10.1.253 table uplink_isp1
post-up ip route del default via 10.10.1.254 table uplink_isp1
post-down ip rule del from 10.10.1.253 table uplink_isp1# ISP2
auto eth1
iface eth1 inet static
address 10.10.2.253
netmask 255.255.255.0post-up ip route add 10.10.2.254/32 dev eth0 src 10.10.2.253 table uplink_isp2
post-up ip route add default via 10.10.2.254 table uplink_isp2
post-up ip rule add from 10.10.2.253 table uplink_isp2post-up ip route del 10.10.2.254/32 dev eth0 src 10.10.2.253 table uplink_isp2
post-up ip route del default via 10.10.2.254 table uplink_isp2
post-down ip rule del from 10.10.2.253 table uplink_isp2
You can also setup additionnal per-link routes in a such setup.