Fixing NIC Name in Cloned VMWare Linux Machines
A suspected bug with certain versions of VMware ESX causes cloned Linux VMs to obtain a sequentially-number NIC. For example, if the parent VM had eth0, the clone will have eth1, and the clone of that clone will have eth2, etc. This can cause issues with centralized configuration management, among other things.
To change the NIC name to the default eth0, you need to do to things: edit the relevant ifcfg-eth*
and edit 70-persistent-net.rules
. Here’s an example:
# ifconfig -a | grep ^eth eth2 Link encap:Ethernet HWaddr 00:50:56:84:4F:B6
Edit the ifcfg-eth[0-9] that handles the eth2 NIC (it may or may not be called ifcfg-eth2: you’ll have to look inside).
cd /etc/sysconfig/network-scripts /bin/mv ifcfg-eth2 ifcfg-eth0 sed -i 's/eth2/eth0/g' ifcfg-eth0
The next step is to edit the udev rules:
vi /etc/udev/rules.d/70-persistent-net.rules # Remove any extraneous lines, leaving only those # that correspond to the actual NICs and assign # correct eth names
Finally and unfortunately, reboot the server. A slightly hacky way of renaming the NIC does not require a reboot, but does cause a brief loss of network connectivity (so do it from console). And keep in mind, this would not survive the reboot. You will still need to do the steps above:
ifconfig eth2 down ip link set eth2 name eth0 ifconfig eth0 up