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 got my two ISPs:

  • 10.100.36.0/29
  • 10.200.36.0/29

I got my two networks:

  • 10.45.13.0/27
  • 10.45.15.0/27

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 10.45.13.0/27 to 10.100.36.0/29 and 10.45.15.0/27 to 10.200.36.0/29.

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

  • 10.100.36.2 (eth0)
  • 10.200.36.2 (eth3)
  • 10.45.13.1 (eth1)
  • 10.45.15.1 (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.

EDIT

root@ROUTER-DEB:/sst# ip route
10.200.36.0/29 dev eth3 proto kernel scope link src 10.200.36.2 metric 30
10.100.36.0/29 dev eth0 proto kernel scope link src 10.100.36.2 metric 40
10.45.15.0/27 dev eth2 proto kernel scope link src 10.45.15.1 metric 10
10.45.13.0/27 dev eth1 proto kernel scope link src 10.45.13.1 metric 10
default via 10.45.15.1 dev eth2 scope link metric 10
default via 10.45.13.1 dev eth1 scope link metric 10
default via 10.200.36.1 dev eth3 metric 30
default via 10.100.36.1 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

1 Answer 1

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 10.100.36.1 table isp_100
    ip route add 10.100.36.0/29 dev eth0 src 10.100.36.2 table isp_100
    ip route add default via 10.200.36.1 table isp_200
    ip route add 10.200.36.0/29 dev eth3 src 10.200.36.2 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 10.45.13.0/27 instead of iif eth1. Doesn't make a difference if nothing more than 10.45.13.0/27 is behind eth1. Interface names may change. But if later a subnet behind 10.45.13.0/27 is created then from 10.45.13.0/27 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 : serverfault.com/questions/507380/… –  David Bélanger May 13 '13 at 19:03

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.