Setting virtual interface names in KVM/Qemu (tap devices)

kvm-virtualization

I have a few KVM machines that I put under a private network using tap devices. I have also setup their /etc/network/interfaces so that each one gets proper ip address.

I copied my setup to another machine and I see that when KVM VM's are brought up, the virtual interfaces get different names than the orginal setup. Thus /etc/network/interfaces does not work.

I tried to set virtual interface name using "name" attribute of the "-net nic" option. But that did not work.

Does anyone know how to fix this problem?

Best Answer

How did you set up the virtual machines in the new KVM server?

example: When you clone a virtual machine, KVM will generate new MAC ADDRESS for the interfaces... Since the MAC ADDRESS is not the same, the interfaces will have new names, because the interfaces files from the previous configuration are there, so, eth0 will not appear thus creating eth1 - At least this is how Red Hat like distros will behave..

Since you don't say what distro are you using, maybe checking the virtual machines MAC ADDRESS and change /etc/network/interfaces accordingly may help you..