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