Once Windows 8 RC was released, and Hyper-V for the client OS was working, I was immediately excited. I could now have virtual machines run locally without having to install a server operating system onto my machine. I got my machine up and running with the Windows bits, and I then tasked myself into getting the virtual machines going. Everything was really quick and easy to get going; however, when it came to having a private network for my virtual machines to talk on and also have access to the external world, it was pretty frustrating. The main reason I want this is to have static routes so that I can RDP into my virtual machines instead of using the Connect… window that Hyper-V gives us. I have to give almost all the credit of this blog post to Martin Hinshelwood for showing me, very briefly, how he managed to set it up. I’m not sure if I replicated his configuration exactly, but this is definitely working for me without a problem.
Hyper-V Network Switches
The first thing that you will need to do is set up your network switches within Hyper-V to allow this setup. So, if we open up Hyper-V Manager and go to the Virtual Switch Manager, you will see the following dialog:
Figure 1: Creating a virtual switch
You get the option of creating either an External, Internal, or Private switch within Hyper-V. We’ll be creating two separate switches to be able to do this, External and Internal. The names are pretty self-explanatory, but there is also the Private option. What is this for? This is almost identical to Internal, except that Internal networks gives the virtual machines access to the host machine, and vice-versa, whereas the Private switch does not allow this. So, first thing is first, let’s go ahead and create an External Virtual Switch.
Now, the next part is important to pay attention to, especially if you’re on a laptop. If you have wireless and wired NICs on your computer, you will have to be specific as to which one you choose. I’m mainly on my wireless card on my laptop, so I have mapped that specific NIC to this switch. I’ve left all the default settings and named the switch Public.
Figure 2: Creating an External virtual switch
Once this has been created, go ahead and select the New virtual network switch one more time and create an internal network switch. Again, I left the default settings and named it Private.
Figure 3: Creating an Internal network
Okay, so now we have our virtual switches up and running (yay!). Let’s move on to set up of the connections on our local machines. This is absolutely needed so that the virtual machines will have a gateway to talk to.
Local Machine Network Configuration
So, on our local machine we will now have two active networks on our local machine in the Network and Sharing Center. They will both be vEthernet connections because Windows 8 has some crazy stuff in the background. No worries, though, we only need to change a little configuration on our private network virtual switch.
Figure 4: Setting up the local host’s network configuration
Above is the workflow of menus you need to go through to get to where you set up a static IP for your local machine on the internal virtual switch. Here are the steps:
- Click on vEthernet (Private) hyperlink to open status window.
- Click on Properties
- Find and select Internet Protocol Version 4 (TCP/IPv4) and then click Properties again.
You will find yourself at the IPv4 Properties pane. Follow configure it with these settings:
- Choose Use the following IP address radio button
- IP address: I used 22.214.171.124 but you can use whichever IP address you like. (I really like the number 5 J)
- Subnet mask: 255.255.255.0
- Click Ok and Close twice.
This will get you back to your Network and Sharing Center. We are now finished with setting up our local machine’s configuration. Time to move onto the virtual machines.
Virtual Machine Configuration
Now, to get our virtual machines connected to both of these networks, we have to connect them up to the switches in the Hyper-V Manager.
Figure 5: Connecting the virtual machine up to the virtual switches (external and internal)
Above, I have selected my machine (the one labeled [126.96.36.199] – ALM 2010 RTM) and then clicked Settings…. This will bring up the settings pane for the selected virtual machine. From here, you need to make sure that you have added two Network Adapters and connect one to the Private switch and the other to the Public switch. If the virtual machine only has one Network Adapter select the Add Hardware at the top of the list on the left and add a new one. Once the machine has been hooked up to the switches, click Ok and start up the virtual machine.
Connect to the virtual machine by selecting it and clicking Connect… in the bottom right pane of the Hyper-V Manager. Once connected, log into an administrator role on the machine and open up the Network and Sharing Center within the virtual machine. In the virtual machine, you will notice that it looks almost identical to your local machine, except the two connections are not vEthernet‘s.
Figure 6: Configuring the virtual machine’s network configuration
This is almost identical to what we did to the local machine except we want to give this virtual machine its own static IP address (I gave mine 188.8.131.52) and then put our local machine as the default gateway. Once done, click Ok and then Close twice to return to the Network and Sharing Center. Everything should be set up correctly, and you should be able to run ipconfig in a command prompt and see the correct results.
Figure 7: Confirming the network settings
Now that this has been verified, we should be able to remote into the machine from the local host (as long as it has the appropriate RDP settings), and the virtual machines will be able to talk to one another on the private network.