VMWare Image Clone Problem: eth0 Renamed As eth1


After cloning a VMWare image I had noticed that my CentOS Linux server renamed eth0 as eth1, eth1 as eth2 and so on. This is due to wrong or duplicate mac address. To fix this problem login to your CentOS Linux server using console and type the following commands:




# cd /etc/udev/rules.d
# cp 70-persistent-net.rules /root/
# rm 70-persistent-net.rules
# reboot

This file was automatically generated by the /lib/udev/write_net_rules program, run by the persistent-net-generator.rules rules file. Simple delete it and reboot the system to recreate the same. This should fix the problem:

# /sbin/ifconfig | grep "^eth"
Sample outputs:

eth0      Link encap:Ethernet  HWaddr 00:0C:29:F3:E4:14
eth1      Link encap:Ethernet  HWaddr 00:0C:29:F3:E4:1E
You need to remove the MAC address in /etc/sysconfig/networking-scripts/ifcfg-eth*. To find out current MAC address, enter:

# ifconfig -a | grep eth1 | grep HWaddr | awk '{ print $5}'
# ifconfig -a | grep eth2 | grep HWaddr | awk '{ print $5}'

Update your /etc/sysconfig/networking-scripts/ifcfg-eth0 with eth1 HWaddr (MAC address), enter:

# cat /etc/sysconfig/networking-scripts/ifcfg-eth0
Sample outputs:
 
DEVICE="eth0"
BOOTPROTO="dhcp"
NM_CONTROLLED="yes"
ONBOOT="yes"
HWADDR="00:0C:29:69:0C:4A"
 
Save and close the file. Restart the network service, enter:

# service network restart
You can verify new settings with the following commands:
# /sbin/ifconfig -a
# route -n

More About udev

udev is the device manager for the Linux kernel series 2.6.xx. udev loads all modules asynchronously in a different order. This can result in devices randomly switching names. My guess is my network card switched names or renamed eth0 and eth1 as eth1 and eth2.