Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Why might route-eth0 be ignored but route-eth1 not? Might be because eth0 is using DHCP and eth1 is statically-configured?

I have some static routes configured in

[16:20:06][root@zserver2:/etc/sysconfig/network-scripts]$ ls -al ro*
-rw-r--r-- 1 root root 104 Dec  6 15:49 route-eth0
-rw-r--r-- 1 root root 106 Dec  6 15:49 route-eth1

When I do a service network restart the routes for eth1 are activated but NOT those for eth0.

An ifup eth0 also ignores them, but an ifup-routes eth0 is just fine. What's the best way of getting it activated?

[16:18:36][root@zserver2:/etc/sysconfig/network-scripts]$ service network restart
Shutting down interface eth0:  Device state: 3 (disconnected)
                                                           [  OK  ]
Shutting down interface eth1:  Device state: 3 (disconnected)
                                                           [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  Active connection state: activating
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/28
state: activated
Connection activated
                                                           [  OK  ]
Bringing up interface eth1:  Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/29
                                                           [  OK  ]

route info

[16:18:50][root@zserver2:/etc/sysconfig/network-scripts]$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.15.10   192.168.15.11   255.255.255.255 UGH   1      0        0 eth1
192.168.15.11   0.0.0.0         255.255.255.255 UH    0      0        0 eth1
192.168.15.11   192.168.15.91   255.255.255.255 UGH   1      0        0 eth1
192.168.15.0    0.0.0.0         255.255.255.0   U     1      0        0 eth0
0.0.0.0         192.168.15.1    0.0.0.0         UG    0      0        0 eth0

ifup eth0 manually

[16:19:03][root@zserver2:/etc/sysconfig/network-scripts]$ ifup eth0
Active connection state: activating
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/30
state: activated
Connection activated

route info

[16:19:35][root@zserver2:/etc/sysconfig/network-scripts]$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.15.10   192.168.15.11   255.255.255.255 UGH   1      0        0 eth1
192.168.15.11   0.0.0.0         255.255.255.255 UH    0      0        0 eth1
192.168.15.11   192.168.15.91   255.255.255.255 UGH   1      0        0 eth1
192.168.15.0    0.0.0.0         255.255.255.0   U     1      0        0 eth0
0.0.0.0         192.168.15.1    0.0.0.0         UG    0      0        0 eth0

ifup-routes eth0 manually

[16:19:56][root@zserver2:/etc/sysconfig/network-scripts]$ ./ifup-routes eth0
[16:20:00][root@zserver2:/etc/sysconfig/network-scripts]$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.15.1    192.168.15.90   255.255.255.255 UGH   5      0        0 eth0
192.168.15.10   192.168.15.11   255.255.255.255 UGH   1      0        0 eth1
192.168.15.10   192.168.15.1    255.255.255.255 UGH   5      0        0 eth0
192.168.15.11   0.0.0.0         255.255.255.255 UH    0      0        0 eth1
192.168.15.11   192.168.15.91   255.255.255.255 UGH   1      0        0 eth1
192.168.15.0    0.0.0.0         255.255.255.0   U     1      0        0 eth0
0.0.0.0         192.168.15.1    0.0.0.0         UG    0      0        0 eth0

Config files are:

ifcfg-eth0

[16:30:26][root@zserver2:/etc/sysconfig/network-scripts]$ cat ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
UUID=76ef8242-9e22-4a29-93f3-a142d1460c87
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
HWADDR=00:25:90:86:71:E0
PEERDNS=yes
PEERROUTES=yes
LAST_CONNECT=1386361279

ifcfg-eth1

[16:30:35][root@zserver2:/etc/sysconfig/network-scripts]$ cat ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
UUID=647f66bd-67b2-4e9a-b5a5-4280ad677b9a
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth1"
IPADDR=192.168.15.91
PREFIX=32
HWADDR=00:25:90:86:71:E1
LAST_CONNECT=1386361279
share|improve this question

2 Answers 2

The problem is likely timing. Among other things, the ifup script does this:

  • puts eth0 in an "up" state
  • starts dhclient to obtain an IP address
  • loads static routes from route-eth0

The problem is that ifup doesn't wait for dhclient to get an IP address before trying to load your static routes, and the kernel won't install a route for an interface without an IP address configured on it.

If you must use DHCP, one solution is to let dhclient add the routes for you. Per the manpage for dhclient-script(8) from CentOS 6.5:

Immediately after dhclient brings an interface UP with a new IP address, subnet mask, and routes, in the REBOOT/BOUND states, it will check for the existence of an executable* /etc/dhcp/dhclient-up-hooks script, and source it if found. This script can handle DHCP options in the environment that are not handled by default. A per-interface /etc/dhcp/dhclient-${IF}-up-hooks script will override the generic script and be sourced when interface $IF has been brought up.

You should be able to make this work by creating a /etc/dhcp/dhclient-eth0-up-hooks script containing the following:

/etc/sysconfig/network-scripts/ifup-routes eth0
share|improve this answer

That would be my conclusion as well. DHCP i/f's get their routing info from the DHCP server, so these files are ignored, when that's the case.

You should be able to go through NetworkManager and add addtional routes through the UI.

Example

          ss of nm1

             ss of nm2

          ss of nm3

share|improve this answer
    
Thanks @slm, but I tried adding through the Network Manager and it just put the same data in route-eth0. –  Ian Worthington Dec 6 '13 at 22:20
    
@IanWorthington - perhaps you're getting tripped up by the issues discussed in this forum thread? forums.fedoraforum.org/showthread.php?t=219788 –  slm Dec 6 '13 at 22:22
    
You mean NM not really updating the file? It does, I checked it with different value. Also noted later that it carefully blew away my device value... Won't be using that again. –  Ian Worthington Dec 7 '13 at 14:57
    
@IanWorthington - yes the updates of the files. So the changes show up then? –  slm Dec 7 '13 at 15:23
    
Changes I make through the NM gui show up in the files, yes. And just found that ifup calls nmcli if NM is active and never bothers with ifpost which would call ifeth/ifroutes/... –  Ian Worthington Dec 7 '13 at 15:51

Your Answer

 
discard

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.