Thursday, January 27, 2011

Setting up two NICs on two separate LANs provides error

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 10.2.0.0 dev eth0 src 10.2.0.1
ip route add 10.1.0.0 dev eth1 src 10.1.0.1

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.

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

    Aeo : 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?
    From lorenzog
  • 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 10.2.0.20 for eth0 and 10.1.0.20 for eth1. The netmask for both is 255.255.255.0. The gateway for eth0 is 10.2.0.1 and the gateway for eth1 is 10.1.0.1. You want all traffic to go through eth0 except 10.1.0.0/24 and 10.3.0.0/24 which go through eth1.

    In ifcfg-eth0 you have:

    DEVICE=eth0
    IPADDR=10.2.0.20
    NETMASK=255.255.255.0
    BOOTPROTO=static
    ONBOOT=yes
    

    In ifcfg-eth1 you have:

    DEVICE=eth1
    IPADDR=10.1.0.20
    NETMASK=255.255.255.0
    BOOTPROTO=static
    ONBOOT=yes
    

    In /etc/sysconfig/network you have:

    NETWORKING=yes
    HOSTNAME=whatever
    GATEWAY=10.2.0.1
    

    In /etc/sysconfig/network-scripts/route-eth1 you have:

    10.3.0.0/24 via 10.1.0.1
    
    Aeo : 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.
    From embobo

0 comments:

Post a Comment