At work I have been making more and more use of virtualization. To make life simple, I have a virtual machine image that I use as a template and clone it when I need a new virtual machine. This works great, except that as part of the cloning process, the clone receives a new MAC address (which is expected). The problem is, udev has already linked eth0 to the templates MAC address, so the clone’s network card is configured as eth1, not eth0. Not a big deal, but annoying (to me anyways).
Here is the workaround I found that tells udev to ignore KVM/Xen/Vmware issued MAC addresses.
In the file /lib/udev/rules.d/75-persistent-net-generator.rules, find the line:
Below that line add the following lines:
# Ignore KVM virtual interfaces
# This eems to be the range used by Xen, but also by virt-clone
# Ignore VMware network interfaces identified by vendor part of MAC addr
Now that I’ve added these rules to my master image, all the copies I make have their NIC assigned to eth0.
- Tested on Ubuntu Server 10.04 LTS, though it should work on any distro that uses udev in the same manner.
- I’ve only used this trick on VMs with a single NIC. I’m not sure what will happen on multihomed installs.