Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 wish I had found this before starting in, but it's too late for that...

I am running CentOS 5.5.

I started following this guide for setting up two NICs on different networks. Everything was going fine until I hit this step:

This part allow the routing to the direct neigbor over the good interface :

ip route add dev eth0 src
ip route add dev eth1 src

I am hit with the following error when I try to do those commands:

RTNETLINK answers: Invalid argument

I am not very experienced in server setup. However, I have been tasked to do this, so I look for help. Any suggestions on where to go from here?

Alternatively, any suggestions on how to undo what I have done so far, in order to give the other guide listed above a try?

Edit: I forgot to mention, this server also has the tool Webmin installed, if that should help any.

share|improve this question
you need to setup 2 default routes to use 2 ISPs to connect to internet like in the guide? or only 2 NICs to have access to 2 networks like a normal router? To undo you only need to remove the modifications you made to rt_table (optional but I would prefer to do it) and restart the server or network (not sure how to do this on CentOS but on Ubuntu it's /etc/init.d/networking restart) as if you followed the guide, the modifications are not persisted. – laurent Sep 7 '10 at 14:40
On CentOS it's (as root) service network restart (or /etc/init.d/network restart) – brent Sep 7 '10 at 14:43
Thanks for the info on undoing it. That will certainly ease my tensions about this whole thing. As for the 2 ISPs, bit more complicated than that. eth0 has access to the internet. eth1 also has access to the internet, but I would prefer it didn't. eth0 is the interface we will be serving pages over, and eth1 will be the internal office network. They are two different LANs entirely, however should never need to serve anything up over eth1. The objective of this is to increase FTP speeds. We had been uploading to the servers over the internet which slowed the whole office down. – Aeo Sep 7 '10 at 14:56
up vote 6 down vote accepted

That guide is convoluted and not the standard way to do it in CentOS.

You aren't specifying the netmask so I guess it is assuming a class A based on the IP address, in which case they are on the same subnet and the second route command would replace the first. Run ip addr ls, ifconfig, route -n, or netstat -rn to see.

Now, I'm not sure what you are trying to do but it is best to take it in steps. First, you configure the interfaces then you add your routing. The CentOS method for configuring the interfaces is to edit /etc/sysconfig/network-scripts/ifcfg-eth0 and ifcfg-eth1. You configure your default route in /etc/sysconfig/network. You configure additional routes in /etc/sysconfig/network-scripts/route-eth0 and route-eth1.

Here are my assumptions. Change to match your setup. The IP addrs of your CentOS box are for eth0 and for eth1. The netmask for both is The gateway for eth0 is and the gateway for eth1 is You want all traffic to go through eth0 except and which go through eth1.

In ifcfg-eth0 you have:


In ifcfg-eth1 you have:


In /etc/sysconfig/network you have:


In /etc/sysconfig/network-scripts/route-eth1 you have: via
share|improve this answer
I did as stated and it seems to be working flawlessly. Thank you! I've spent two days puzzling over this, so seeing it finally working is wonderful. – Aeo Sep 7 '10 at 18:06

Do your ethernet devices have such IPs? I.e. does eth0 have and eth1 Or better - couldn't that be a typo, so that eth0 must have and eth1

share|improve this answer
I don't really know if it's a typo or not. I know just enough about networking to adapt the schema to fit our network setup. Beyond that, it's all educated guessing. Feel free to correct me if I'm wrong, but would not switching those two IPs actually confuse the two separated sides? – Aeo Sep 7 '10 at 14:49

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.