Setting up internet access for Hyper-V with NAT in Windows 8

In my work with development of SharePoint solutions, I heavily rely on virtualized environments on my own laptop computer. Working inside virtualized environments complicates the configuration of your own infrastructure, and to get and acceptable user experience inside the virtual machines a working internet connection is a requirement.

Earlier Hyper-V was only supported on the server OS, but from Windows 8 this has also been added to the client OS as well.  Since I run this on my laptop computer, connected to different networks from time to time, it gives me some other requirements for the internet access than traditional fixed location Hyper-V setups. Setting up an external virtual network switch could give me internet access, but also connects the virtual machine directly to the host network. Exposing the virtual machines on the host network has many disadvantages, so setting up a NAT’ed solution where they are hidden behind the host computer’s network connection would be a better solution to me.

Creating a new virtual switch in Hyper-V

Start by opening the Hyper-V Manager, and locate the  Virtual Switch Manager in the Actions menu.

Create a new virtual network switch by selecting New virtual network switch, give it a name (in this example “Shared”) and select the connection type Internal.

Configure internet access for the new virtual switch

The next step is to share your current internet connection on the host with the newly created virtual network switch in Hyper-V.

Open Control Panel -> Network and Internet -> Network Connections.

Right click on your connection who has access to internet (in this example “Wi-Fi”), and select Properties.

Select Allow other network users… and select the newly created virtual network switch (prefixed with “vEthernet”). The name in this case is the save as entered as name for the virtual network switch, in this example “Shared”.

After selecting OK the virtual network swich will get a static IP of 192.168.137.1, and serve as a DHCP server within that range for the virtual machines.

Enable internet access on virtual machines

In Hyper-V Manager, select a virtual machine and Settings from the menu. Make sure the virtual machine is powered off first.

Choose to add new hardware, network adapter and select the newly created virtual network switch. Power on the virtual machine, and a new network adapter with NAT’ed internet access should appear. The adapter should have been assigned a dynamic IP-address from the 192.168.137.x range.

Summary

In this walk through we have seen how to configuring NAT’ed internet access for virtual machine in Hyper-V. Even if this guide was created for Windows 8, most of the steps can be applied both on Windows Server 2008 R2 and 2012 with the same result.

27 thoughts on “Setting up internet access for Hyper-V with NAT in Windows 8”

  1. Note that in the step where you select “Allow other network users”, if you only have a single other network connection, there will not be a box to allow you to select “Home networking connection”. It will just assume the other connection for you.

  2. Hi, this solution looks exactly for what I needed, but on my System the VMs don’t get adresses via dhcp, even the virtual switch had its 192.168.237.1 address. Any ideas?

      1. Not sure what can be wrong. Verify that the virtual network adapter, Shared, has been assigned the IP-address 192.168.137.1. If not, retry the steps with sharing a current network adapter with internet access. Check that the correct adapter is added to the virtual machine, and if it was powered on during the sharing of the internet connection you need to renew the assigned IP address. If the DHCP doesn’t assign a IP-address, try to assign one manual on the virtual machine within the 192.168.137.x range and with 192.168.137.1 to verify that the internet sharing actually works. Hope this can help figuring out where the problem is!

      2. Not sure if it’s supported, but you could assign a static IP on the virtual machine to accomplish that. A better solution could be to add another virtual network of type “internal” and set up your own IP range and use static IP-addresses. Those will also be reachable from the host machine, which I guess is your main goal.

  3. HI,

    I have done all the above steps, but still it does not show access type “Internet” in Network and Sharing Center for the new connection.

    Its it assigned the IP, but still it does not connected to internet. any other steps

  4. Just awesome! Thanks for the tip. I’ve been trying to use Hyper-v for my lab, and was struggling to figure out how to get NAT working. Almost threw in the towel too, and use vmware instead. Again, Thanks!

  5. Hello Are,
    Great article, however, my intended purpose is to create a Server VM which is running it’s own DHCP. Is it possible to use this method without DHCP on the virtual nic?
    KInd regards,
    Ben

    1. I’m not sure, but it is possible to set your own DHCP, DNS, etc as long as you keep the gateway for internet access on the adapter. Maybe adding another network adapter for this purpose also could be a good choice?

  6. I am running Hyper-v on Win 8. And I have installed Win server 2008 R2 as a guest OS. I want to make this guest OS as a domain controller with static IP. And at the same time I want this OS to get internet connectivity from the host machine. Is it possible?

  7. My firewall on my Windows 8 system was preventing the guest xp machine from getting a dhcp ip address. Check your firewalls on the host system.

  8. It was not Working for me at first, then instead of physical network I shared My VEthernet(Which is my vSwitch for the Hyper-v linked to my physical NIC) and it worked for me. My environment is Windows server 2012 R2.

  9. After I followed your steps I had Internet neither on the host, nor on the guest. I had to first disconnect from the Wi-Fi network and reconnect again. Now it’s working!

  10. Hey Aren, great post congrats. I work as support engineer here in Brazil, I already brought one new computer, and my Wirelless NIC does not support the features needed by hyper-v to work as external. So, i tried to update the drivers, get one dump during the configuration of external switch (it was hanged) and after research about ICS and be redirected to your blog, it worked! thank you so much

  11. Thanks so much for this article. I set it just like described and works like a charm, the only thing i needed to create an External adapter in Hyper-V first and share it instead of directly the physical NIC and all is good.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s