How to setup & configure your Hyper-V guest virtual machines to connect to the Internet & to your host windows 8 Laptop or server 2012 to share folders (External & Internal virtual switches)

Building development and presentation or demo Virtual Machines on Windows 8 professional laptops or desktops and using Microsoft Hyper V is now fairly common. Hyper V server is now available to work on Windows 8 professional which was previously only possible on Windows Server 20012 (and 2008). We used to have to build our laptops on windows server 2012 operating system due to this limitation previously but now it is very common to have hyper-v running on Pre-Sales Consultants and Architects laptops (and even tablets such as Surface now).

A common challenge/issue with the setup of Hyper-V Virtual Machines is the internal and external networking of the virtual machine and how you can get your Virtual Machine to work internally within your LAN so that it can connect to your host machine (Laptop or Desktop PC) and so that it can also have external Internet Connectivity. This also applies to setting up your Hyper-V server using Windows Server 2012 so that its guest virtual machines and the host server are all connected to one network and all have external connection to the Internet.

This topic has probably covered by many before but I still found that some people are stills struggling with it, hence I decided to write this post. I’ll try to make the post clear and focused in the form of bullet points to be an easy guide for anyone trying to setup the network adaptors on their Virtual Machines.

First thing you need to know is that I strongly recommend that you have two network adaptors in your Virtual Machine (VM): Internal and External adaptors. Similarly, you need to have two virtual switches created in your Virtual Switch Manager in Hyper-V: Internal Switch and External Switch to be used by the two virtual adaptors in your Virtual Machine.

Internal Adaptor will allow for the Virtual Machine to be accessible from within your host machine so that you can Remote Desktop (RDP) to your Virtual Machine using this internal linkage between your host (laptop or PC) and the VM. You also need this internal connection for sharing folders between the host and the virtual machine and to map network drives between them.

The External Adapter is required to allow for your Virtual Machine to be able to connect to the Internet through the host machine physical network card (NIC) (via the external switch).

Each virtual Adapter on a virtual machine requires a virtual Switch to be created on Hyper-V server.

So, firstly, you need an Internal Virtual Switch to get your internal VM adapter to use the host physical NIC (Network Card). Screenshot of how your virtual switch (internal) can be configured is below:

Virtual Internal Switch
Virtual Internal Switch

For this Internal connection, I suggest that you specify a static IP address for your Virtual Machine’s internal virtual adapter and your host’s internal adapter. This is to ensure that any shares between host and VM and the RDP connection have constant connection based on this IP. The IP address I used was for example: 192.168.2.20 and 192.168.2.21 for host & VM respectively with the VM’s default gateway equals to the Host IP (192.168.2.20).

You will then need an external virtual switch. When you create a new external virtual switch, the switch takes over from your physical host machine network card (NIC) and your NIC becomes just bridged to this external switch. Similarly, your Virtual Machines Adaptor will just connect to this virtual switch (external) and will then have the VM connected to the Internet. The external switch can be setup to connect to Ethernet or Wifi. I have chosen to make it to work with Ethernet. You can have another one for Wireless connection if you prefer. Screen shot of external virtual switch configuration is below:

Virtual External Switch
Virtual External Switch

When creating the external virtual switch please make sure that the option to: “Allow operating system to share the external switch” is ticked to allow for the Operating system to get the physical NIC of the host to connect to the internet via the external virtual switch.

Let’s say you have an Internet Router at home and you have done the above setup for the external virtual switch and virtual adapter in the VM, you will find that your external switch will take an IP address from this Router, your host machine will have a different IP as if it is a different device and your Virtual Machine’s external adapter will have another IP from the router. So 3 different IPs. I suggest that you keep these IP’s dynamic especially if this setup is on a your laptop or demo machine. The reason is that you must be connecting to different Internet connections via different routers and switches which each will give you a different IP for your virtual external switch. In this case, if your IPs are static, then every time you connect to a new Internet router, you need to change the IPs of all 3. If they are dynamic, then you do not need to do anything.

This means that your VM can be accessible internally from the host machine using this IP and this internal network via the router. You might here say then we do not need an internal virtual switch as the external one is enough. This is only true as long as you got your virtual switch connected to the If you disconnect your external virtual switch from the router, then you will not be able to access your VM from the host as the VM will lose this IP address and if you decide to use static IP addresses for this external connection, you will find that every time you go from home to office, you need to change IP addresses of the external adapters.

Hence, and for all of the above reasons, I strongly suggest that you have an internal virtual switch for permanent connection between your host and virtual machine… and an external virtual switch for Internet connection for both your VM and your host machine (Laptop/PC/Server).

Notes:

  • Please note that after creating the Virtual External Switch, the switch takes over the connection so you might need to restart your host machine.
  • Once restarted and as long as the option to allow operating system to share the external switch is ticked as mentioned before, then the host will get connected to the Internet as well.
  • If you started the Virtual Machine while the host is not connected to the Internet, you may need to renew the VM’s external adapter IP address. Either Disable & then Enable the VM’s external adapter if you want to renew the IP or simply run the renew IP command in a command prompt on the virtual machine. This is the case when you have a dynamic IP address on the VM’s external adapter.
  • Make sure you choose meaningful names for your virtual switches both external and internal and for your Virtual Machine virtual adapters.
  • Below is a screen shot of how my host machine (Windows 8 Laptop) has its network adapters named:
    Host Machine Network Adapters
    Host Machine Network Adapters

    Hyper-V names all virtual network adapters with vEthernet and then the name of the virtual switch between brackets. So you will find in the snapshot above that:
    vEthernet (Virtual External Switch) connects to my Hyper V Virtual External Switch and the other one for the Virtual Internal Switch.

  • Below is a screen shot of how the virtual machine network connection adapters look:

    Guest Virtual Machine Network Adapters
    Guest Virtual Machine Network Adapters
  • I also found the following post and video helpful:

http://www.eightforums.com/tutorials/19359-hyper-v-virtual-switch-manager.html
http://www.youtube.com/watch?v=-IoZJYQeq4U

5 Replies to “How to setup & configure your Hyper-V guest virtual machines to connect to the Internet & to your host windows 8 Laptop or server 2012 to share folders (External & Internal virtual switches)”

  1. I just found this article and it seems like it is missing the rest of the tutorial. With the internal and external nics set how do we configure it so it uses the external for internet and internal for file sharing?

    1. And can we limit sharing of some folders on our host to only one adapter and others to both adapters? (I have folders I want to expose to the Vclients only and some to the whole network.)

    1. True in principal – but if you move the host across different networks, you will find that sometimes you don’t want your VM accessing your company domain or the internet via your company domain or in some cases unable to get an IP from the domain that allows for Internet access. In this case, you need the internal switch to have the internal access and you can temp switch off the external one. As a good practice (in my humble view), you should have one for internal and internal connectivity (RDP from host, etc.) and one for external for internet only.

Please comment or leave feedback