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 have a Linux box with two interfaces.
eth0 has ip
eth1 has ip
I need all traffic for subnets to go through eth1 and all the rest to go through eth0.
Which is the best way to do this?
route command?
Cheers for the help.

share|improve this question
up vote 3 down vote accepted

Just set routes to your desired Networks over eth1:

route add -net netmask dev eth1
route add -net .........

And then set your default gateway to whatever you need:

route add default dev eth0

(Nevertheless a route using an interface looks a bit strange to me - usually you should address the gateways using the correct router(s):

route add -net netmask gw <your routers IP>
share|improve this answer
route add -net netmask gw <your routers IP> worked like a charm. Cheers for the help. How would I go about making the changes stick after reboot on a Debian based distro? – user2284355 Jul 8 '13 at 12:22
You can add commands in /etc/network/interfaces that should be executed after the interface is up using the keyowrkd "up" in your interface section. F.e.: "up route add -net ......." – Pascal Schmiel Jul 8 '13 at 12:39
route add default gw <eth0 gateway> dev eth0
route add netmask gw <eth1 gateway> dev eth1
route add netmask gw <eth1 gateway> dev eth1
route add netmask gw <eth1 gateway> dev eth1

That ought to do it.

share|improve this answer

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.