RHEL – Creating Stable Names for Network Interfaces

devicesethernetlinuxrhel

We have a RHEL 5.5 box with 8 interfaces. And the eth interface naming is flip flopping. Sometimes eth0 comes up on physical port 7th, and sometimes on another physical port.

We want the naming to be as per the sequence of PCI BUS. I did the research and found that

cat /sys/devices/pci0000\:00/0000\:00\:1e.0/0000\:07\:07.0/net\:eth0/address\

This locations have the mac address of the eth devices. So If I get "address" in sequence from this pci bus locations and put them in ifconfig-eth0 to ifconfig-eth7 in order of PCI BUS location, my eth naming will be stable.

I tried:

find /sys/devices/ -name "address"

but it does not bring any results. I don't know why…

Any help here?

Best Answer

Have you tried including the MAC addresses in the different ifcfg-ethX files for the various ethernet devices? Additionally you can control which device get's which ethX handle through udev's 60-net.rules file.

For example

# /etc/sysconfig/network-scripts/ifcfg-eth0

# Intel Corporation 82573E Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=static
DHCPCLASS=
HWADDR=00:30:48:56:A6:2E
IPADDR=10.10.10.15
NETMASK=255.255.255.192
ONBOOT=yes

Then in the file /etc/udev/rules.d/60-net.rules:

KERNEL=="eth*", SYSFS{address}=="00:30:48:56:A6:2E", NAME="eth0"

I believe this information is used to keep the devices configured consistently from boot to boot.

Configuring more than one ethX device

To deal with more devices simply setup each devices corresponding /etc/sysconfig/network-scripts/ifcfg-ethX file, and add another line to the 60-net.rules file.

KERNEL=="eth*", SYSFS{address}=="00:30:48:56:A6:2E", NAME="eth0"
KERNEL=="eth*", SYSFS{address}=="00:30:48:56:A6:2F", NAME="eth1"

The above is how you do it in CentOS 5.X. The file changes in CentOS 6.x to 70-persistent-net.rules, and the format is slightly different too:

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="54:52:00:ff:ff:dd", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

References

Related Question