0

I have the following routing table

10.0.1.0/24 dev eth0  proto kernel  scope link  src 10.0.1.151
10.0.10.0/24 dev eth1  proto kernel  scope link  src 10.0.10.151
default via 10.0.1.1 dev eth0

I have two links, one goes through a LAN and, through 10.0.1.1 out to the Internet. The other is a ADSL router (10.0.10.1) directly attached to eth1.

If I connect from the outside to the external IP address of 10.0.10.1 I get a timeout. If I change the default route to 10.0.10.1, connecting from the outside to the external IP address of 10.0.10.1 works. So this looks like a routing problem (packets come from 10.0.10.1, but go out of 10.0.1.1, being the default route), but I'm not sure how to solve it.

I actually want the default route to be 10.0.1.1, I just want to answer requests to the external IP of 10.0.10.1 via the same interface.

1 Answer 1

3

you need to use advanced routing tables offered by iproute2. You set up 2 tables and send all traffic coming from an ip to a specific table, in this table you can set a default gateway. To set the global default route you just prefer one interface over the other via metrics.

an example:

  • adding the default gateways to the tables:

ip route add default via 10.0.1.1 table 101

ip route add default via 10.0.10.1 table 102

  • add a rule that every traffic coming from a specific ip is send to the table:

ip rule add from 10.0.1.151 lookup 101

ip rule add from 10.0.10.151 lookup 102

  • add the metric which gateway to prefer:

ip route add default via 10.0.1.151 metric 1000

ip route add default via 10.0.10.151 metric 2000

i hope this helps to get you started :)

1
  • in the last part, did you mean ip route add default via 10.0.1.1 metric 1000?
    – Vinko Vrsalovic
    Sep 8, 2010 at 14:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .