mhm so linux cannot handle this problem? I thought it must be very simple to use default route for eth0 if traffic comes from eth0 and use default route from eth1 if traffic comes from eth1.
For what situation is then the dev eth0 / dev eth1 parameter in the route add command for default gateways?
Main Topics
Browse All Topics





by: lanboyoPosted on 2009-11-05 at 00:56:59ID: 25747689
This is somewhat difficult to do unless you know all of the networks that should go out thru eth0.
From the command line;
route add -net 192.168.10.0 netmask 255.255.255.0 gw 192.168.0.1
(assuming the gateway on eth0 is 192.168.0.1) will route traffic to the 192.168.10.0/24 network thru eth0.
route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.0.1
will route all of the 192.168 networks that way... Since these routes are more specific than the default route, they will get routed out eth0.
These route commands will need to be added every time the box boots up, so you will need to add them to rc.local or another appropriate startup config file.
If you do not know what devices will connect from eth0, then you may have to do some kind of trickiness to get it to work, like using a different device to do network address translation to make incoming traffic to look like it comes from the local interface connected to eth0.