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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

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. pacman –database Command Examples in Arch Linux
  2. xclip Command Examples in Linux
  3. btrfs scrub Command Examples in Linux
  4. CentOS / RHEL : How to install Open Virtual Machine Tools for Virtual machines Hosted on VMWare
  5. How to add or delete a samba user under Linux
  6. cpupower: command not found
  7. Understanding kdump Configuration file /etc/kdump.conf
  8. How to monitor NVME drives on Centos 6
  9. Understanding the job control commands in Linux – bg, fg and CTRL+Z
  10. bpftrace Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright