If you’ve ever had to troubleshoot networking issues on a virtual machine, I share your pain.  I recently had a several day battle with my VM that eventually ended in win for me, but not without changing everything up to a wired connection and reading more than I wanted to about switches.  The problem with working remotely is that, if your VM refuses to connect, you become the IT guy whether you like it or not!

I’m nowhere near an IT expert with networking.  Most of my knowledge comes from the articles I glossed through, giving me dozens of little tidbits along my journey (back to where I was the day before at 5pm anyway).  The consensus among the experts is that networking on a VM can be touchy and require some trial and error.  Again, I’m not an expert, but hopefully the articles below and a google search around some of these buzz words will point you in the right direction.

The breakdown

Sometime between Thursday at 5pm and Friday at 7am, my virtual machine could no longer connect to the internet.  “An ethernet cable is unplugged”.  This was straightforward enough, except I was on a laptop connecting wirelessly and didn’t even have an ethernet port on my computer!  Time to dig in.

Basics

No matter what you do, you will have to mess with switches.  This is a good place to start.

Creating a switch

A virtual machine connects to the internet through the host OS by way of a switch.  To create a new switch in Hyper-V, read:  https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/get-started/create-a-virtual-switch-for-hyper-v-virtual-machines  This guide shows you how to create an internal switch (communicates between VMs and the Host), an external switch (gives VM access to network), or a private switch.

Enabling a switch

From the Hyper-V manager, right click your VM and choose settings.  With Network Adapter selected on the right, you can choose a virtual switch for the VM to use.

Display all Network Connections

You will spend a fair amount of time here.  There’s multiple ways to get to the Network Connections window, but this seemed to be the quickest:  Hit Windows + X, choose ‘Network Connections’, and click ‘Change adapter options’.

Any switches you create above will show up here.  For example, I created a switch called ‘External’.

Connecting Wirelessly

This creates an internal switch for the virtual machine and uses Internet Connection Sharing.

I did not find this to work for me, but I did manage to ‘catastrophically’  break things while trying this solution.  If you get a ‘catastrophic failure’ message after setting things to shared, hyper-v may break on you:  http://www.hurryupandwait.io/blog/understanding-networking-options-with-a-wireless-hyper-v-host-and-solving-catastrophic-failure-0x8000ffff.  My theory is that Hyper-V manages many of the more hidden flags and settings and internet connection sharing seems to be doing the same type of thing with hidden flags and they just don’t play nice together.

Connecting With a Wire

I tried more solutions, but eventually gave up and bought an ethernet to USB adapter from this company: https://en.j5create.com/collections/networking, though I bought it from Office Max.  Not ideal having to buy something, but if it works and gets me out of this mess then I’m fine.  This obviously needs an available connection, but it’s a good solution if you didn’t know you could connect to via an adapter and USB.

There is plenty of literature around connecting with a wired connection, but it comes down to creating an external switch and assigning that to your VM.  This article shows this method and the method above as well:  https://www.technig.com/connect-hyper-v-machines-to-internet/

Summary

In summary, this problem is one that just takes trial and error.  This article might not solve your problem, but it hopefully gives you a few more ‘trials’ and puts you in the right direction.  Good Luck!