Centos 6/RHEL change eth1 back to eth0 or rename device

Occasionally because of a hardware change (you may have used a different ethernet device & then removed it) your original eth0 gets it's name changed to eth1, or if using a number of devices the names get changed around out of the order in which you prefer to see them. This can be annoying and you may want to change the names back. You can do this by altering two files in your system.

First go into /etc/udev/rules.d/ 

Vi and Vim commands

$ sudo vi /etc/udev/rules.d/70-persistent-net.rules 

First establish if there are any unused devices still present and delete the entry, remembering to rename or remove the corresponding ifcfg file in /etc/sysconfig/network-scripts.

For example, above I want to delete the old eth0 entry and then find the eth1 device I am still using but wish to rename and change the NAME parameter from eth1 back to eth0.

So make your adjustments or removals in 70-persistent-net.rules and then go to /etc/sysconfig/network-scripts where you will alter and rename the ifcfg-eth1 file.

$ sudo vi /etc/sysconfig/network-scripts/ifcfg-eth1

eth1 renamed to eth0
Change the parameters to suit, DEVICE="eth0" etc, not forgetting the HWADDR, which is the Mac address from the ifconfig or dmesg command. Then you can rename it as in the examples above where you can see the that the Hwaddr for eth0 in the lower image is the same as the Hwaddr for the renamed eth1 from the top image.

$ sudo mv /etc/sysconfig/network-scripts/ifcfg-eth1 /etc/sysconfig/network-scripts/ifcfg-eth0

Or write a new file completely with contents similar to below


Which are typical parameters for someone using a static IP address on a wired ethernet card. Finally, issue the command

$ sudo service network restart

Or reboot your system to enable the new named device.

Labels: , , , ,