Thursday, December 2, 2010

Fix Missing eth0 When Cloning Ubuntu VMware Virtual Machines

I've found this site: http://www.orzeszek.org/blog/2010/07/25/fix-missing-eth0-when-cloning-ubuntu-vmware-virtual-machines/ that explains how to resolve this issue:

Fix Missing eth0 When Cloning Ubuntu VMware Virtual Machines
by Chris on 25 July 2010

I ran into an annoyance trying to clone some Ubuntu LAMP virtual machines that I was using for website development. Every time I cloned the virtual machine, eth0 would go missing, and ifconfig would show only the loopback device, lo.

It turns out that when you clone a VMware virtual machine, the cloned virtual machine’s network interface gets a new MAC address (which, of course, it must to work on the same LAN). But Ubuntu, and many other Linux distributions, cache the old MAC address in a configuration file.

In Ubuntu, the file is /etc/udev/rules.d/70-persistent-net.rules. After cloning, it will contain a reference to the old network interface as eth0.

The easiest way to fix this problem is to simply delete the file. Ubuntu will regenerate it properly the next time it boots up.

sudo rm /etc/udev/rules.d/70-persistent-net.rules

After deleting the file, you need to reboot. After rebooting, ifconfig should show eth0 and everything should just work.

If you’re feeling less adventurous, you can rename the file to *.old so that you can restore it if something doesn’t work:

sudo mv /etc/udev/rule.d/70-persistent-net.rules /etc/udev/rule.d/70-persistent-net.rules.old

You can also edit the file to remove the old reference to eth0, and rename the new eth1 reference to eth0. But deleting the file and rebooting seems more convenient.

The relevant filename is slightly different in other Linux distributions. For example, in Debian, the filename is /etc/udev/rules.d/z25_persistent-net.rules.

P.D.: (03-08-2011) - In Suse 9 you must delete the file /etc/sysconfig/network/ifcfg-eth-id-xx:xx:xx:xx:xx:xx where xx:xx:xx:xx:xx:xx is the old MAC address.