AcloudA

Ensuring client Hyper-V guest VMs external network connectivity for laptops roaming between different connections

Posted by Mikhail Rodionov on March 27, 2020
Tags: ,


With recent developments and measures, being taken around the world in response to COVID-19 situation, home office mode became new normal and everyone whose job allows that is switching to new modus operandi. I took my laptop back home and switched to remote work mode too. Amongst other things, it led me to rediscover some forgotten issues and difficulties. One of those is the inability of Hyper-V to use a wireless adapter in a way that enables connectivity both for Hyper-V host and guest VMs. I remember running into this issue years ago but back then my household had wired network connectivity available, so I just stick to a more stable and fast wired connection for my laptop and give up on fixing and researching this problem.

But this time I had no wired connection available and it was necessary for me to have internet connectivity both for my Windows 10 1909 Hyper-V host laptop and my Ubuntu Hyper-V VM simultaneously. So easiest and quite logical thing you can try is just changing underlying network adapter for your External Switch from wired to wireless as shown below:

Reconfiguring existing External Virtual Switch to use wireless network adapter

Reconfiguring existing External Virtual Switch to use wireless network adapter

In the past (think of year 2013 / Windows 8.1) such configuration settings were causing virtual switch configuration change operation to fail, later on it become possible to select that but did not work properly. So, what is the situation now? Actually, it just works 😊 Providing that you uncheck “Enable virtual LAN identification for management operating system” checkbox as on the screenshot shown above. Unfortunately, I had it enabled which left me in a situation with Internet working on guest VM while not working on my laptop. That lead me to some googling to research reasons and workarounds of such “limitation”, finding out that at the time of Windows 10 Anniversary Update (August 2016) workaround for this issue used to be to set up network address translation (NAT) for a virtual network. These steps basically involved three lines of PowerShell:

Create NAT Switch using PowerShell

Create NAT Switch using PowerShell

Next, you need to connect your VM to newly created NAT Switch and cope with the requirement of manually assigning IP configuration settings for guest VM.

But at the end of the day looking through Microsoft documentation and forums as well as fiddling with different configuration options not only allowed me to confirm two things.

First thing is that in current Windows 10 builds External Switch bound to wireless network adapter just works as long as you uncheck VLAN ID option, though I was not able to find any information as to which point it becomes a working/supported option.

Second, and more important thing, is another and the easiest solution which just works for laptops roaming between wired connection in the office and wireless at home and other places – Default Switch. Windows 10 Fall Creators Update (released in October 2017) introduced Default Switch which specifically designed for such scenarios and allows virtual machines to share the host’s network connection using NAT (Network Address Translation). It works exactly as advertised, i.e. “Virtual machines connected to it will have access to the host’s network whether you’re connected to WIFI, a dock, or Ethernet. It will also work when the host is using a VPN or proxy.” The only downside is that you need to give up custom network configurations or static IP address options for your guest VMs.

To conclude if you want your Hyper-V VMs to have external connectivity while your laptop switches between wireless and wired connections you should configure your VM network adapters to use Default Switch, as shown on sample screenshot below:

Configuring VM to use Default Switch

Configuring VM to use Default Switch

This is preferred and optimal configuration for roaming laptops when you need to have external network connectivity for your Hyper-V VMs irrespectively of connection used by Hyper-V host. I hope that sharing this may help someone get up and running in home office mode now as well as made laptop roaming experience smoother as soon as roaming and leaving your home office to become an allowed option again.

Related materials:

Views All Time
1
Views Today
2
Return to all posts

Azure Log Analytics: The agent had an unknown failure 2147942402
Azure Logic App to Automate your workflows