Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

I want to route traffic between respective ISP assigned /30 and /29 subnets separetly. If traffic comes from one ISP's /30 network, it should be routed to that ISPs /29 network and visa versa. I don't mind if traffic originated in one ISP's /29 network destined to the other ISP's /29 network gets routed in my router (without getting it sent to one ISP and comes back other ISP's link).

My aim is to not to buy two routers for two ISP's. How can I achieve this by using iproute2 tables and policy routing?

share|improve this question

1 Answer 1

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.