• 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

How to change the NIC device name in CentOS / RHEL 6

by admin

The post describes steps to rename a network interface card. Changing NIC device names involves shutting down the interface and bringing it up. For the purpose of this post, we will rename “eth0” interface to “eth1”.

Adding udev Rule

1. Find the MAC address of device you wish to rename.

# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 12:91:0C:F9:B7:98  
          inet addr:172.31.105.216  Bcast:172.31.111.255  Mask:255.255.240.0
          inet6 addr: fe80::1091:cff:fef9:b798/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1720 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1366 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:313797 (306.4 KiB)  TX bytes:282703 (276.0 KiB)
          Interrupt:247 

Here,
eth0 – is the interface you want to rename.

2. Take backup of /etc/udev/rules.d/70-persistent-net.rules file.

# cp -pr /etc/udev/rules.d/70-persistent-net.rules /etc/udev/rules.d/70-persistent-net.rules-bak`date +%F`

3. Edit the /etc/udev/rules.d/70-persistent-net.rules file and add below entry. The name section is the one to be edited. For example, to change the device name from “eth0” to “eth1”.

# vi /etc/udev/rules.d/70-persistent-net.rules :
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="12:91:0C:F9:B7:98", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

Modifying network scripts

1. You will have to rename and edit the network script for the interface you will to rename. First rename the interface script file from “ifcfg-eth0” to “ifcfg-eth1”.

# cd /etc/sysconfig/network-scripts/
# mv ifcfg-eth0 ifcfg-eth1

2. Open renamed device’s config file (ifcfg-eth1) and Change Device=oldname (eth0) to newname (eth1).

# vi ifcfg-eth1
DEVICE=eth1        ### Change it to new device name "eth1"
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=static
HWADDR=12:91:0C:F9:B7:98

3. Down the interface eth0 and start the new interface. We are assuming that eth0 is not the interface used to login into the system, as it will disconnect when you down the interface. Or you can do it from the console of the machine.

# ifdown eth0
# ifup eth1

4. Verify the new settings with ifconfig or ip command.

# ifconfig -a
Note: If you are testing this in a virtual machine on VMWare or VirtualBox make sure you change the MAC address from the Virtual machine settings as well for the device name change to work. Also in some cases you might require a reboot.

Filed Under: CentOS/RHEL 6, Linux

Some more articles you might also be interested in …

  1. fprintd-delete: command not found
  2. CentOS/RHEL – How to Remove stale ISCSI Target Node Information from ISCSI Initiator Server
  3. How to Enable Password Aging in Linux with NIS
  4. ddcutil: command not found
  5. How to install an RPM package into a different directory in CentOS/RHEL/Fedora
  6. How to monitor your CPU on debian or ubuntu systems
  7. What is the purpose of .bashrc file in Linux
  8. lvs Command Examples in Linux
  9. CentOS / RHEL 5 : How to use the faillog command to track failed login attempts
  10. How to Install dmg File on Mac from Command Line

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright