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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • 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. grub-install Command Examples in Linux
  2. CentOS / RHEL 5,6 : How to reinstall GRUB loader from rescue mode
  3. How to Extend the Last Existing Filesystem Partition with Parted
  4. ldd Command Options in Linux
  5. How to Read Audit Log in Linux
  6. top: command not found
  7. “aws route53” Command Examples
  8. bash Command Examples
  9. gbp Command Examples in Linux
  10. ab – Apache HTTP server benchmarking tool (Command Examples)

You May Also Like

Primary Sidebar

Recent Posts

  • “glab pipeline” Command Examples
  • “glab mr” Command Examples
  • “glab mr merge” Command Examples
  • “glab mr” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright