• 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. “-bash: firewall: command not found” – How to resolve in CentOS/RHEL 7
  2. How to Create logical networks to segregate traffic in a data center in RedHat Virtualization (RHV)
  3. How To Disable Or Extend System Logging Rate-limit on CentOS/RHEL 7
  4. sar Command Examples in Linux
  5. “shutdown” Command Examples in Linux
  6. Getting “parsing errors” When Running ‘yum repolist’
  7. How to Configure Separate Port For SSH and SFTP On CentOS/RHEL
  8. How to Manage Oracle database Audit File Directory Growth with cron (ASM Instances Only)
  9. Basics of Ethernet Bonding in Linux
  10. How to Create a Custom Log File Rotation by logrotate in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • vgextend Command Examples in Linux
  • setpci command – configure PCI device
  • db_load command – generate db database
  • bsdtar command – Read and write tape archive files

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright