Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I got my two ISPs:


I got my two networks:


I am able to route 1 ISP to my network using my debian server. However, we now have 2 LANs and 2 ISPs.

I want to route everything coming from to and to

My debian server is a DHCP server and DNS server. It has 4 NIC cards. IPs are :

  • (eth0)
  • (eth3)
  • (eth1)
  • (eth2)

I've been searching on google since yesterday but nothing on my solution here and I barelly understand the routing system.

My system is brand new by the way,

Thanks you.


root@ROUTER-DEB:/sst# ip route dev eth3 proto kernel scope link src metric 30 dev eth0 proto kernel scope link src metric 40 dev eth2 proto kernel scope link src metric 10 dev eth1 proto kernel scope link src metric 10
default via dev eth2 scope link metric 10
default via dev eth1 scope link metric 10
default via dev eth3 metric 30
default via dev eth0 metric 40
share|improve this question
The nexthop IPs for the networks are missing. You can't route to a network, just to a host address. – Hauke Laging May 8 '13 at 20:47
@HaukeLaging Can you give me an hint on how to preceed please – David Bélanger May 8 '13 at 21:02
I request information that is necessary for provoding a solution and that is your "answer"? Or is that your way of saying "I don't know what the nexthops are"? What is the output of ip route? – Hauke Laging May 8 '13 at 21:09
@HaukeLaging I don't know how route work. I never played with that so, no I don't. I edited to add my ip route. Thanks. – David Bélanger May 8 '13 at 21:15
If you don't know how route works, maybe you should find somebody who does? You need policy routing. – Sandor Marton May 8 '13 at 21:19
up vote 1 down vote accepted

You need advanced routing, source routing in this case. You need two routing tables (one for each ISP) and at least one rule for table selection.

  1. Add two lines to /etc/iproute2/rt_tables. The numbers don't matter; this is just for using names instead. Let's call the tables isp_100 and isp_200.
  2. Define the routing tables:

    ip route add default via table isp_100
    ip route add dev eth0 src table isp_100
    ip route add default via table isp_200
    ip route add dev eth3 src table isp_200
  3. Define the rules for table selection

    ip rule add type unicast iif eth1 priority 100 table isp_100
    ip rule add type unicast iif eth2 priority 101 table isp_200

You could use from instead of iif eth1. Doesn't make a difference if nothing more than is behind eth1. Interface names may change. But if later a subnet behind is created then from wouldn't work any more. On the other hand: In that case the routing on this system would have to be adapted anyway. So make your choice. Most important is that you remember what you have to adapt in case of changes to the network (or system hardware).

Your main routing table defines how the system itself (locally generated packets) connects to the Internet.

You may need a script that executed the ip route commands every time the network subsystem is restarted. My experience with openSUSE is that a subsystem restart does not affect the ip rule settings. So these probably need be done only once after system boot.

You can check the current rules by ip rule and the tables by ip route table isp_100.

share|improve this answer
Hi. Thanks for your answer. I did try it today with the from IP but it didn't work. I'll try again tomorrow at work with the iif. The ip rule gave me last thing as before so I think I just didn't do it right in the first place. – David Bélanger May 9 '13 at 2:18
Also. Do I need to clear the table before I put the route you gave me ? – David Bélanger May 9 '13 at 2:22
@DavidBélanger What I showed you above is an addition to your normal routing table. Thus in general that one need not be cleared (but in this special case it need be as it's quite broken). – Hauke Laging May 9 '13 at 2:38
I was able to make it work with what you see there :… – David Bélanger May 13 '13 at 19:03

Your Answer


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.