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

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • 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. CentOS / RHEL 7 : How to disable Transparent Huge pages (THP)
  2. The /var/log/messages is empty, and so are the rotated log files such as messages.0, messages.1
  3. How to Disable or set SELinux to Permissive mode
  4. How to install/remove/query/update RPM packages in Linux (Cheat Sheet)
  5. What are Shell Scripts? How to Create Shell Scripts?
  6. “uname” Command Examples to Check UNIX/Linux Version
  7. How to Disable Daylight Savings Time (DST), and Modify the Timezone on Linux
  8. How to Force ASM to Scan the Multipathed Device First using ASMLIB/oracleasm
  9. Installing Security Vulnerabilities with yum on CentOS/RHEL 5,6,7 (Cheat Sheet)
  10. How to add or delete a samba user under Linux

You May Also Like

Primary Sidebar

Recent Posts

  • Oracle Database – Configuring Secure Application Roles
  • Extend rule sets by using factors in Oracle Database Vault
  • What are Command Rules in oracle Database
  • Using Rule Sets in Oracle Database Vault
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary