0

I'm trying to automate the network interface setup that will be used on identical boxes. The boxes have 3 different NICs. Each of the 3 NICs have different MAC prefixes that I can use to differentiate them by and I have set up udev rules that map them to predictable names by using wildcard matching on the MAC address using the appropriate MAC prefix.

However, I'm having trouble mapping the interface by name to the desired IP configuration on Centos 6.5. I can't use the normal way (HWADDR) since that uses the full MAC address and they will be different on each box, so I'm trying to match on DEVICE name. The problem seems to be with the NetworkManager daemon.

What I have done, is to set up ifcfg-device files in the /etc/sysconf/network-scripts directory. For example, ifcfg-i1:

DEVICE=i1
TYPE=Ethernet
BOOTPROTO=none
IPADDR=10.102.30.158
PREFIX=24
GATEWAY=10.102.30.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
ONBOOT=yes
UUID=9ff7691b-e65b-4f9b-b6f2-e7549662403b

Everything works fine, if the interfaces all come up before the NetworkManager daemon starts. However, if this service starts before the 3 interfaces are "ready", the service sets the interface to a different IP than the one in its ifcfg file. Here are the relevant lines from /var/log/messages from a case where the IP is wrong:

Jul 31 18:19:14 centos6 kernel: ADDRCONF(NETDEV_UP): i1: link is not ready
Jul 31 18:19:14 centos6 kernel: ADDRCONF(NETDEV_UP): i2: link is not ready
Jul 31 18:19:14 centos6 kernel: e1000e: i1 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: Rx/Tx
Jul 31 18:19:14 centos6 kernel: ADDRCONF(NETDEV_CHANGE): i1: link becomes ready
Jul 31 18:19:14 centos6 kernel: ADDRCONF(NETDEV_UP): i3: link is not ready
Jul 31 18:19:14 centos6 kernel: e1000e: i2 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
Jul 31 18:19:14 centos6 kernel: ADDRCONF(NETDEV_CHANGE): i2: link becomes ready

Now the NetworkManager service starts, but i3 hasn't become ready yet.

Jul 31 18:19:15 centos6 NetworkManager[2350]: <info> NetworkManager (version 0.8.1-66.el6) is starting...
Jul 31 18:19:15 centos6 NetworkManager[2350]:    ifcfg-rh: parsing /etc/sysconfig/network-scripts/ifcfg-lo ...
Jul 31 18:19:15 centos6 NetworkManager[2350]:    ifcfg-rh: parsing /etc/sysconfig/network-scripts/ifcfg-i3 ...
Jul 31 18:19:15 centos6 NetworkManager[2350]:    ifcfg-rh:     read connection 'System i3'
Jul 31 18:19:15 centos6 NetworkManager[2350]:    ifcfg-rh: parsing /etc/sysconfig/network-scripts/ifcfg-i1 ...
Jul 31 18:19:15 centos6 NetworkManager[2350]:    ifcfg-rh:     read connection 'System i1'
Jul 31 18:19:15 centos6 NetworkManager[2350]:    ifcfg-rh: parsing /etc/sysconfig/network-scripts/ifcfg-i2 ...
Jul 31 18:19:15 centos6 NetworkManager[2350]:    ifcfg-rh:     read connection 'System i2'
Jul 31 18:19:15 centos6 NetworkManager[2350]:    ifcfg-rh: parsing /etc/sysconfig/network-scripts/ifcfg-em1 ...
Jul 31 18:19:15 centos6 NetworkManager[2350]:    ifcfg-rh:     read connection 'System em1'

Eventually i3 does become ready:

Jul 31 18:19:16 centos6 kernel: e1000e: i3 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
Jul 31 18:19:16 centos6 kernel: ADDRCONF(NETDEV_CHANGE): i3: link becomes ready
Jul 31 18:19:17 centos6 NetworkManager[2350]: <info> (i1): device state change: 7 -> 8 (reason 0)
Jul 31 18:19:17 centos6 NetworkManager[2350]: <info> Policy set 'System i1' (i1) as default for IPv4 routing and DNS.
Jul 31 18:19:17 centos6 NetworkManager[2350]: <info> Activation (i1) successful, device activated.
Jul 31 18:19:17 centos6 NetworkManager[2350]: <info> Activation (i1) Stage 5 of 5 (IP Configure Commit) complete.
Jul 31 18:19:17 centos6 NetworkManager[2350]: <info> (i3): carrier now ON (device state 2)
Jul 31 18:19:17 centos6 NetworkManager[2350]: <info> (i3): device state change: 2 -> 3 (reason 40)
Jul 31 18:19:17 centos6 NetworkManager[2350]: <info> Auto-activating connection 'System i1'.
Jul 31 18:19:17 centos6 NetworkManager[2350]: <info> Activation (i3) starting connection 'System i1'
Jul 31 18:19:17 centos6 NetworkManager[2350]: <info> (i3): device state change: 3 -> 4 (reason 0)

But by this point NetworkManager has decided that i1 is the default policy and assigns the i1 IP (10.102.30.158) to i3 too.

I tried adding NM_CONTROLLED="no" in the ifcfg-xxx files, but the NetworkManager log then shows:

warning: NM_CONTROLLED was false but HWADDR or SUBCHANNELS was missing; device will be managed

for the interfaces, so that had no effect. I can't use HWADDR since I can't use exact MAC addresses.

First, is this a bug? Everything works fine if the interfaces are up before NetworkManager starts, so the results depend on a race condition.

If it's not a bug, how can I accomplish this? Disabling NetworkManager is probably not an option.

4
  • I haven't fully read your question but checkout blog.hacka.net/#post64, which I have previously used to rename the interface based on MAC address, basically uses udev. This is just a suggestion.
    – Vikyboss
    Jul 31, 2015 at 19:48
  • I already set up a udev rule that sets the interface name, that's not the problem. The problem is assigning an IP based on the name, not the MAC address. IP addresses are not assigned by udev.
    – pcarter
    Jul 31, 2015 at 20:10
  • 1
    One option is simply to disable NetworkManager (and make sure you have the legacy network script enabled).
    – larsks
    Aug 3, 2015 at 13:58
  • Try disabling NetworkManager and then see if you still get the warning, errors, etc. Also, see what happens with BOOTPROTO=static instead of "none".
    – ILMostro_7
    Oct 24, 2015 at 4:22

1 Answer 1

0

I posted this question to the Centos 6 Networking forum and the response there was that using HWADDR is the only supported method (at least for NetworkManager).

They suggested that I generate the ifcfg-device files with the exact MAC address before the network comes up. That would be straightforward using a init script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.