How to Setup Hyper-V Networking on Windows 8

[Update 7. oct. 2013: Check out the follow up post here – it shows a better way]

It seems that the best way to setup networking in Hyper-V on a Windows 8 machine is quite far from obvious. I have spent some time getting this working as it should, so read on…

The Goal

Is quite simply that I want my VMs to just work seamless with my Host machine and whatever network connection I’m using and – in my case – a guest AD.

This used to be really simple with VMWare Workstation but after converting my machines to Hyper-V there is a catch or two.

Note that this applies to a mobile working scenario where I run everything on a laptop and it frequently changes whether I’m using a wired, wifi or mobile net.

The Environment

I do SharePoint development and this post is written in that context, however it should all be generally applicable to Hyper-V.

My local Hyper-V (SharePoint Dev) environment consists of two guests:

  • An AD server that should not communicate outside my box
  • A SharePoint server that need to communicate with my host, the guest AD and generally networking

In addition I need to connect with Remote Desktop to the guest machines with the host (the Hyper-V console is useless for all but boot and network configurations).

The Hyper-V Network Settings

The steps to configure the network on the host are:

  1. Create an external virtual switch for each of your external network adapters in the Hyper-V manager
  2. Create an internal switch for the connection between host and virtual machines (and in my environment between the AD and SharePoint server)
  3. A catch: In my case the mobile adapter was not selectable (not sure if that is always the case) when I create a virtual switch.

    In that case create an internal switch (name it “External” something as it will be configured for that)

    1. Go to your Network Connections, choose your mobile adapter, Sharing and choose to share the connection with the newly created virtual switch (see the picture below)

  4. Name them all appropriately otherwise you’ll regularly end up being confused 😉

    After that your Hyper-V settings look something like this:

  5. Finally you need to pick some static IP addresses for your internal network as you’ll want the host to communicate with the guests and the guests to be able to talk to each other. There is no DHCP on the internal switch (would be a reasonable feature request for the next version of Hyper-V). I this case I picked 192.168.10.2 for my host:

  6. If you want to be able to refer to your guest machines by their names you need to add a couple of entries to your hosts host file 😉 Edit the file C:\Windows\System32\Drivers\etc\hosts and add a line for each guest

    I picked 192.168.10.10 for my AD guest and 192.168.10.20 for my SharePoint guest:

The Guest Configuration

First of all you need to connect the virtual switches appropriately to your guests in the Hyper-V Manager:

  • For the guests that only need to communicate internally connect only the internal switch
  • For the guests that need full internet access connect all the switches

Finally we need to configure the guests themselves. Connect to each one using the Hyper-V console:

  1. For the AD guest server (internal communication only) assign the ip address 192.168.10.10 (the one picked above) – there should only by one network adapter
    1. When you change the IP address for an AD server you also need to change the address appropriately in the DNS manager. Simply start the DNS manager and click through the nodes and change all IP addresses to the new address
    2. If you have a registration for other clients (other guest machines) update those records to the IP you chose for them
    3. Reboot the guest
  2. For the guests that need network access
    1. Assign the chosen IP to the internal network, in my case, 192.168.10.20
    2. Add two lines to the guest machines host file to make sure that the AD guest server can be found:

      “192.168.10.10 ad01” and “192.168.10.10 ad01.domain.local” where the second is the FQDN of the AD server

    3. You should now have a number of network adapters that are connected to the host’s physical adapters and it will automatically figure out which ones are connected and use whichever is appropriate. I recommend that you named them appropriately in the guest.
    4. Catch (do not skip this): I did however find that it was unable to correctly figure out whether the mobile adapter was connected or not (likely because I created it as an internal switch). I fixed that by prioritizing the mobile network connection last so it will only use the mobile if all others fail. You just need to set the “network metric” to something high (high is lowest priority), follow the process in the picture below

That’s it for the guests!

RDP Access

Finally you’ll want to access the guests through RDP so stuff like copy/paste and fullscreen works. You can of course use whatever RDP manager you prefer, here I’ve just used the standard one.

Make a connection for each Guest access and save it somewhere (Desktop?).

Run the command “mstsc” and setup the options you like and save the Connection. In particular enable “Clipboard” and “Drives” in the “Local Resources” tab. That will enable you to copy/paste both text and files between the guest and host. Will also grant access to the host’s drives.

In my case:

Going for the Advanced Mode?

While the settings above work fine; there is always room for improvement.

I think it would be better to install a third machine as a firewall/router so the firewall handled all external connections and boxed in the essentially rogue guest machines. They really only need to communicate externally on port 80/443.

I will give m0n0all a go soon 🙂

Troubleshooting

Once in a while something goes wrong. Sadly.

My normal way to troubleshoot is simple to do a “tracert http://www.google.dk” and to notice what network adapter is being used for the communication.

Sometimes it picks the wrong nic (one without Internet access) for whatever reason (you did remember to set the metric above, right? This is what it does). “Ipconfig /flushdns” sometime solves the problem otherwise disable the offending nic in the guest (temporarily).

Advertisements

About Søren Nielsen
Long time SharePoint Consultant.

12 Responses to How to Setup Hyper-V Networking on Windows 8

  1. Andy Cronk says:

    This was a fantastic help, I have just moved to Windows 8 and had to transfer all of my virtualbox machines to Hyper-V. This guide allowed me to setup a network with an AD server, a SQL Server and a Web server and it all works perfectly. Thanks for your time in making this available

    • Søren Nielsen says:

      Happy to help 🙂

      On 26/02/2013, at 18.25, “Thoughts on computing, SharePoint and all

  2. Hi Søren, Your info was of great help to me by setting up a virtual development environment with several servers. Next step for me is to connect my virtual domain onto another domain. Do you have any experience to share in that area as well ?
    Regards, Ronald Brink

    • Hi Ronald

      Well I have some experience with ads. Not sure what you are trying to do though.
      If you want to connect a virtual ad to your normal ad forest, it can be done I you ensure that they can reach each other over the network. Then it’s just another ad server 😉

      However I do believe that you should make sure that both ad servers are using static ips for their shared network and also that they can resolve each other using both their netbios and fqdn names.

      Also i would not recommend this if the guest ad is a “portable one”. If it is some machine on your laptop that you move around i think you’ll end up with a lot of small problems. Wouldn’t recommend it. At the very least make sure that your guest ad can only communicate with your other guest and the other ads in the forest. It should not be answering request from any other machines.

  3. Hi Søren, thanks for your advice; I’ll dive into it.

  4. tr0users says:

    Hi S0ren

    On the guest my internal connection to the host is now working and I am able to RDP to the guest and share folder etc – so thanks for this.

    However, I haven’t been able to get internet access from the guest.

    I’m using a ThinkPad laptop that has a built in mobile adapter into which I’ve inserted a 3g SIM. This gives good internet access for the host.

    I have followed you instruction to create another virtual switch, selected as “Internal” but named “Mobile External”.

    Within the guest network connections I have two networks which I have named “Internal” and “MobileExternal”. I manually assigned a local ip address for the “Internel” network and this works ok. For the “MobileExternal” network I have left at “Obtain an IP address automatically”.

    on the guest I have a yellow triangle with an exclamation mark over the network icon in the task bar. I guess this is because it’s not been able obtain an IP from the “MobileExternal” network.

    Could you please advise what I’ve done wrong?

    Many thanks,

    Rob

    • Hi rob

      I think you are pretty close. It sounds to me that all you need to do is share the network from the host.
      In your hosts network adapter settings choose your normal 3G adapter. Go to properties, the last tab should be something about Internet sharing. Enable this and link the host physical 3G adapter with the logical hyperv adapter mobileexternal.
      In the list of adapters one the status column should read something like “Internet access, shared”.

      That should be it 🙂

      Then the connection is available to your guest.

      • tr0users says:

        When I first tried to do this (before posting the question) the option so select vEthernet (Mobile External) wasn’t available to select on the Sharing Tab of the mobile broadband options. However, when I went back it was there! It now works great – many thanks for your help and the excellent blog post

  5. Ana says:

    Hi!
    You are writing
    “The Guest Configuration
    First of all you need to connect the virtual switches appropriately to your guests in the Hyper-V Manager:
    For the guests that only need to communicate internally connect only the internal switch
    For the guests that need full internet access connect all the switches”

    Could you please explain the step “For the guests that need full internet access connect ALL the switches”?
    In the settings for each guest VM, under Network Adapter you can choose only one network connection!? Am I missing something?

    Thanx,
    Ana

  6. Pingback: Simple(r) Hyper-V Networking on Windows 8 | Thoughts on computing, SharePoint and all the rest

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

%d bloggers like this: