Linux VMs running Hyper-V lose network connectivity when Live Migrated or Restarted

I ran into a problem not too long ago where a Linux VM running in Hyper-V lost network connectivity when it was restarted, or when it was Live Migrated between hosts in a Hyper-V cluster.

At first I verified all of the normal things, I made sure it was connected to the right Virtual Network, I made sure the Microsoft Network Virtual Switch Protocol was the only protocol enabled on the NIC for that Virtual Network on both Hosts in the cluster. I also made sure that the VM was using a Legacy Network Adapter instead of a Network Adapter.

I logged into the VM itself via the console and ran an ifconfig, the only adapter that showed up was lo (the loopback adapter). I thought this was odd, as I just configured eth0 not too long ago. I verified that the /etc/network/interfaces file had the proper network settings configure for eth0, which it did.

At this point I had to do some research and I found that the newer linux kernels use the MAC address of the NIC instead of the hardware ID of the device to assign a logical eth number to each network card. I checked within the VM’s Settings and sure enough the Legacy Network Adapter on the VM was set to dynamic MAC address instead of Static. I changed the setting to Static, and kept the currently assigned MAC address as it’s static MAC address.

Inside the VM I can an ifconfig -a and saw that interface eth1 was available, but not configured. I edited the /etc/network/interfaces file to say eth1 instead of eth0 and then restarted the networking services by issuing the following command: sudo /etc/init.d/networking restart. Sure enough I was able to start accessing the network.

I did a restart and a Live Migration and was able to continue accessing the network.

One thought on “Linux VMs running Hyper-V lose network connectivity when Live Migrated or Restarted

  1. Andrew Galdes

    Ubuntu does this because HyperV ‘can’ randomly choose a MAC address for the guest. When the guest boots, it gets a new MAC for each interface and therefore assumes it’s a new ethernet device.

    I say “Ubuntu” because i am not sure if others do it too.

    This can be corrected in the host config for each guest. Essentially set the MAC to static. in HyperV for the guests.

    -Andrew Galdes

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *