Linux – virtual interface names in qemu/kvm

kvm-virtualizationlinuxqemu

I have an image with a debian-squeeze installation and using that I created two overlay-images to boot two (nearly identical) virtual machines from.

When I boot them up individually (connecting them to a vde-switch and specifying the mac-adress in the qemu/kvm command-line) everything works as I would expect.

However when I run them simultaniously something odd is happening:

The first machine to boot works as expected and creates a "eth0"-interface, but the second machine does not create "eth0" but "eth1" instead.

Can someone please explain this behaviour?

What would be the best way to ensure that in all vms the virtual network interface has the same name?

Many thanks!

Best Answer

Most Linux systems use udev to tie an interface name to a specific MAC addresses (so that machines with multiple NICs have the interfaces consistently named across boots). This however causes this problem when the MAC address does change (like when booting in a VM with a different MAC address set) but you don't want a new interface name assigned. To clear these mappings, delete the appropriate file in /etc/udev/rules.d/ (usually named 70-persistent-net.rules) and reboot. In your case you want to do this while creating the master image.