I have a Linux box running Ubuntu 10.04 with three interfaces: eth0, eth1 and eth2.
I am planning to use it as a WAN router for 4 public subnets assigned by two different ISP's.
Here are the subnets (I have converted the ISP assigned subnets to class C private subnets):
ISP 1
WAN 192.168.0.176/30 gateway 192.168.0.177
LAN 192.168.3.192/29
ISP 2
WAN 192.168.6.208/30 gateway 192.168.6.209
LAN 192.168.9.216/29
/30 subnets face respectives ISPs and /29 subnets face my LAN switch.
This is how IPs are assigned to the interfaces:
LAN interface
eth0 192.168.3.193/29
eth0:0 192.168.9.217/29
ISP 1 interface
eth1 192.168.0.178/30
ISP 2 interface
eth2 192.168.6.210/30
First, create a routing table for each ISP (only done once):
echo "11 isp1" >> /etc/iproute2/rt_tables
echo "12 isp2" >> /etc/iproute2/rt_tables
Then add a default route to each table pointing to the corresponding gateway:
ip route add default via 192.168.0.177 table isp1
ip route add default via 192.168.6.209 table isp2
Then add rules to send traffic to these tables based on the source address:
ip rule add from 192.168.3.192/29 table isp1
ip rule add from 192.168.0.176/30 table isp1
ip rule add from 192.168.9.216/29 table isp2
ip rule add from 192.168.6.208/30 table isp2