How to set persistent NIC device name with PCI slot via udev instead of MAC address in Red Hat Enterprise Linux 6
Environment
- Red Hat Enterprise Linux (RHEL) 6
Issue
- Is it possible to create custom udev rules to use the PCI address of network card for persistent naming instead of the MAC address?
Resolution
-
First make sure the standard
biosdevname
feature will not fulfill your needs. More information is at Solution 159723-
Ensure that console access is available in the event there are issues impacting connectivity during this process
-
If
biosdevname
does not meet your requirements, start by identifying the PCI address of your Ethernet interfaces withlspci
# lspci -D | grep Ethernet 0000:03:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5719 Gigabit Ethernet PCIe (rev 01) 0000:03:00.1 Ethernet controller: Broadcom Corporation NetXtreme BCM5719 Gigabit Ethernet PCIe (rev 01) 0000:03:00.2 Ethernet controller: Broadcom Corporation NetXtreme BCM5719 Gigabit Ethernet PCIe (rev 01) 0000:03:00.3 Ethernet controller: Broadcom Corporation NetXtreme BCM5719 Gigabit Ethernet PCIe (rev 01)
-
Create an
/etc/udev/rules.d/60-persistent-net.rules
as it needs to come before the RHEL generated70-persistent-net.rules
udev rule. Note the use ofNAME:=
to disallow later changes to value.# 0000:03:00.0 Ethernet controller: NetXtreme BCM5719 Gigabit Ethernet PCIe (rev 01) was eth0 ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:03:00.0", NAME:="primary" # 0000:03:00.1 Ethernet controller: NetXtreme BCM5719 Gigabit Ethernet PCIe (rev 01) was eth1 ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:03:00.1", NAME:="app1" # 0000:03:00.2 Ethernet controller: NetXtreme BCM5719 Gigabit Ethernet PCIe (rev 01) was eth2 ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:03:00.2", NAME:="app2" # 0000:03:00.3 Ethernet controller: NetXtreme BCM5719 Gigabit Ethernet PCIe (rev 01) was eth3 ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:03:00.3", NAME:="backup"
-
Modify
/etc/sysconfig-network/scripts/ifcfg-*
files to utilize new names in theDEVICE=
value.# grep ^DEVICE= ifcfg-* | grep -v =lo$ ifcfg-app1:DEVICE="app1" ifcfg-app2:DEVICE="app2" ifcfg-backup:DEVICE="backup" ifcfg-primary:DEVICE="primary"
-
Use
udevadm
to test rules to make sure name setting is working# udevadm test /class/net/eth0 2>&1 | grep NAME udev_rules_apply_to_event: NAME 'primary' /etc/udev/rules.d/60-persistent-net.rules:2
-
-
Reboot the system and review that the changes have been made as expected.
NOTE: This was tested on system that is NOT using NetworkManager (ie. NM_CONTROLLED=no
in ifcfg-* files)
Diagnostic Steps
Some Red Hat documents for reference:
- http://fedoraproject.org/wiki/Features/ConsistentNetworkDeviceNaming
- http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/6.1_Release_Notes/ar01s01.html
- http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/sect-Consistent_Network_Device_Naming-System_Requirements.html
- https://access.redhat.com/knowledge/articles/53579
Some public site references:
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments