Friday, April 22, 2016

Sharing the Host WiFi with Hype-V image

I use Hyper-V for all of my development work.  Up until now I've been providing internet access to my Hyper-V images by setting up a Virtual Switch in Hyper-V, and configuring it as an Internal network.  When my host is connected to the internet, I use Internet Connection Sharing to this Virtual Switch.  I then configure the Hyper-V images to use a legacy adapter and select this Virtual Switch. Here is how my WiFi adapter is shared.

This procedure is well documented in other posts.  But it has a snag. Internet Connection Sharing insists on using IP addresses in the 192.168.0.* range and your WiFi router must use an alternative IP address range e.g. 192.168.1.* 

I recently upgraded my Virgin broadband and the new router was using the IP range 192.168.0.*  You could supposedly change it but I could not get this to work properly so I started to hunt around for another solution that would leave the IP range unchanged.  I stumbled on the wonderful network bridge.

The solution is the go into Virtual Switch settings and create a new Virtual Switch but select External network. I selected my WiFi network card from the list and enabled "Allow management operating system to share this network adapter".

When you click OK, it takes a minute but what its doing is creating a Network Bridge in your Network Connections along with a  Hyper-V Virtual Ethernet adapter you are probably familiar with.  My virtual machines use the same approach, a legacy adapter that is configured for this external Virtual Switch. 

Now when I look at my Network Connections its a bit odd.  My WiFi adapter displays Enabled, Bridged even when I am not connected to the Internet. When I make the connection in the usual way it is the Hyper-V Virtual adapter that goes through the whole Identifying... stage until it connects.  It looks counter-intuitive but it works a treat.  So that's it. My Hyper-V images are connected to the Internet and I didn't have to change the IP address of the router.

No comments: