• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

HowTos | Basics | Concepts

  • Solaris
    • Solaris 11
    • SVM
    • ZFS
    • Zones
    • LDOMs
    • Hardware
  • Linux
    • CentOS/RHEL 7
    • RHCSA notes
    • SuSE Linux Enterprise
    • Linux Services
  • VCS
    • VxVM
  • Interview Questions
  • oracle
    • ASM
    • mysql
    • RAC
    • oracle 12c
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Hadoop
    • Hortonworks HDP
      • HDPCA
    • Cloudera
      • CCA 131

Configure Persistent NIC Names of Network Adaptors in CentOS/RHEL using udev Rules

By admin

Some deployment requires persistent ethernet adapter name and also requires some rules to keep the consistent NIC name across servers. This could be achieved by ‘udev‘. Let’s take an example to understand the udev rules required for such persistent naming scheme.

The requirement to change the network adapter names as per the deployment need:
1) The network adapter eth7 needs to be made as eth9.
2) The network adapter eth9 needs to be made as eth7.

Configuring persistent NIC names

Following are the steps :-

1. Backup the existing configuration files/folders as follows :

/etc/udev/rules.d/*
/etc/sysconfig/network-scripts/*

2. Edit the udev rules under “/etc/udev/rules.d/” with the following changes in the udev rules file i.e “/etc/udev/rules.d/70-persistent-net.rules” :

Modify the Existing Parameters “eth7” to “eth9” & “eth9” to “eth7

# vi /etc/udev/rules.d/70-persistent-net.rules
# PCI device 0x8086:0x10f7 (ixgbe)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:da:73:d9", ATTR{type}=="1", KERNEL=="eth*", NAME="eth7"      
# PCI device 0x8086:0x105e (e1000e)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:00:c9:df:c4:47", ATTR{type}=="1", KERNEL=="eth*", NAME="eth9"

3. After the changes to udev rule is completed, modify the Network Configuration to match the new changes .i.e. eth7 device should be named as eth9 and vice-versa. Changes are required in the files “/etc/sysconfig/network-scripts/ifcfg-eth7” and in “/etc/sysconfig/network-scripts/ifcfg-eth9”.

# cat /etc/sysconfig/network-scripts/ifcfg-eth7
DEVICE=eth7                                                  
NM_CONTROLLED=yes
ONBOOT=no
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth7"                                      (Modify the Existing Parameter "eth7" to "mgmt-eth9")
UUID=1e690eec-2d2c-007e-535f-a873a2b375d5
PREFIX=26
DNS1=10.253.2.254
HWADDR=00:1b:21:da:73:d9                           
USERCTL=no
# cat /etc/sysconfig/network-scripts/ifcfg-eth9:
DEVICE=eth9                                                 (Modify the Existing Parameter "eth9" to "eth7")
NM_CONTROLLED=yes
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=mgmt-eth9                                          (Modify the Existing Parameter "mgmt-eth9" to "eth7")
UUID=d70dd704-4891-3f2d-b12e-79ffbc7bb9b8
IPADDR=10.253.248.144
PREFIX=26
GATEWAY=10.253.248.129
DNS1=10.253.2.254
HWADDR=00:00:c9:df:c4:47
NETMASK=255.255.255.192
USERCTL=no

4. Reboot the server after implementing the changes as suggested above. If the server reboot is not possible then the udev rules need to be reloaded and the network needs to be restarted to take the changes effectively.

# shutdown -r now
Beginners Guide to Udev in Linux
CentOS / RHEL 5,6 : How to write custom udev rules

Filed Under: CentOS/RHEL 5, CentOS/RHEL 6, Linux

Some more articles you might also be interested in …

  1. How to use shell expansions for generating shell tokens under Linux
  2. How to configure DM-Multipath from an iSCSI initiator to an iSCSI target in CentOS / RHEL
  3. UNIX / Linux : How to delete root equivalent user (Non-Root User with UID 0)
  4. What causes iptables to load every time after a reboot even when it’s completely turned off
  5. How to disable or enable an HBA without reboot under CentOS/RHEL
  6. Linux OS Service ‘hplip’
  7. How to Check if a Service Restart or Server Reboot is required After RPM Package Update (CentOS/RHEL/Fedora)
  8. Linux OS service ‘dhcpd’
  9. “mlock failed: Cannot allocate memory” lvcreate command error in CentOS/RHEL 7
  10. CentOS / RHEL 6,7 : How to recover an interrupted yum package installation

You May Also Like

Primary Sidebar

Recent Posts

  • How to change the default IP address of docker bridge
  • “su: Authentication failure” – in Docker
  • How to Pause and Resume Docker Containers
  • How to find docker storage device and its size (device mapper storage driver)
  • Understanding “docker stats” Command Output
  • Archives
  • Contact Us
  • Copyright

© 2019 · The Geek Diary