Redhat – Centos multiple NICs routing issue

networkingnicredhatroutevlan

I am having trouble setting up permenant routes for my network interfaces,

below my config :

ETH0 :
172.23.137.27 Netmask /25 – 255.255.255.128 Gateway – 192.168.126.126

ETH1 : Trunk VLAN – VLAN ID : 305
172.21.107.123 Netmask /28 – 255.255.255.240 Gateway – 172.21.107.113

interfaces config are as follow :


cat ifcfg-eth0 
DEVICE=eth0
HWADDR=2C:59:E5:42:CB:EC
TYPE=Ethernet
#UUID=eefb4ac8-42ba-4fc3-9918-08aae7edef3b
ONBOOT=yes
#NM_CONTROLLED=no
BOOTPROTO=static
IPADDR=192.168.126.27
NETMASK=255.255.255.128
GATEWAY=192.168.126.126
#USERCTL=no

cat ifcfg-eth1
DEVICE=eth1
HWADDR=2C:59:E5:42:CB:ED
UUID=68f6c45e-48ba-4b33-8da7-d4d7979eb72d
ONBOOT=yes
BOOTPROTO=none
NM_CONTROLED=no

cat ifcfg-eth1.305 
DEVICE=eth1.305
VLAN=yes
ONBOOT=yes
BOOTPROTO=static
TYPE=Ethernet
IPADDR=172.21.107.123
NETMASK=255.255.255.240
GATEWAY=172.21.107.113
#NM_CONTROLLED=no


route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.21.107.112  0.0.0.0         255.255.255.240 U     0      0        0 eth1.305
192.168.126.0   0.0.0.0         255.255.255.128 U     0      0        0 eth0
192.168.192.0   0.0.0.0         255.255.255.0   U     0      0        0 eth3
0.0.0.0         172.21.107.113  0.0.0.0         UG    0      0        0 eth1.30

The default route works only if i insert it manually :
route del default gw 192.168.126.126 eth0

But did not work using : route-eth0 under /etc/sysconfig/network-scripts

Best Answer

For any network device which is not my default gateway, I usually set the default route flag to no:

DEFROUTE="no"

This seems to work without any issues for my servers with multiple network interfaces. If you then restart your network service or interfaces, you should be able to check the routes to see that this is actually working:

/sbin/route -n

Hopefully this helps.

Related Topic