Tired of getting new ethernet interfaces each time you copy/move your VmWare Linux guests ?

If you use VmWare with Debian-based Linux guests (Debian, Ubuntu, etc.) you probably have been annoyed by the following behaviour: You copy / move your guest, or in my case, you boot your guest both from Windows and from Linux; next time you try to boot, you have no network.

Examining the guest you find that there is no "eth0" interface anymore, but new interface "eth1" has appeared and is unconfigured. At this point you can modify your system's configuration in order to use the new "eth1", but then you find yourself in a race you can't win: each time you copy/move/dual boot there is a new eth2, eth3 and so on.

The problem is that the udev subsystem (the component that autoconfigures the system's hardware), binds the ethX interfaces by MAC address, and each time you copy/move/dual boot, a new MAC address is generated by VmWare, and thus a new ethX is created.

There are two solutions to this problem:

  1. You can statically configure a MAC address in your guest's .vmx file for each of the guest's network interfaces. I won't pollute the Internet by repeating the instructions in this page, if you choose to go down this path you can take a look here, here or here.
  2. You also can remove Linux's cached information about previously-detected MAC addresses, as detailed here. Basically what you need to do is to delete all lines from a file located in "/etc/udev/rules.d" named something like "XX-persistent-net.rules", where XX is a two-digit number. After this, you need to reboot your guest.