Re: multiple default routes

From: David Ford (david@kalifornia.com)
Date: Wed May 31 2000 - 13:13:15 EST


> > > I have 2 NICs on each of my Linux boxes connected to 2 different
> > > network segments and routers and I would like packets coming on one
> > > ethernet interface (from any source ip) to go back over the same
> > > interface. Is that possible in Linux ?
>
> I think that's what the original poster wants to do:
>
> eth0: 192.168.1.1 (network 1)
> eth1: 209.186.42.1 (network 2)
>
> route add default gw dev eth1
> route add -net 192.168.1.255 dev eth0

How about this example:

ip address add 192.168.1.1/24 brd + dev eth0
ip link set eth0 up

ip a a 192.168.41.1/24 brd + dev eth1
ip l s eth1 up

ip rule add from 0/0 dev eth0 table 20
ip ru a from 0/0 dev eth1 table 21

ip route add table 20 via 10.0.0.1 dev eth0 onlink
ip r a t 21 via 10.9.9.1 dev eth1 onlink

This sets up eth0 and eth1 with the respective networks and adds rules to
match packets into tables by which they are distinctly routed.

-d

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed May 31 2000 - 21:00:28 EST