I want to be able to take my lab environments with me everywhere I go so I got a new laptop that is powerful enough to run an entire System Center 2012 lab and a couple other labs at the same time. I then installed Server 2008 R2 with Hyper-v as the base OS.
Below I will detail the steps required to gain Internet access via WiFi to Hyper-V hosted labs, while maintaining segregation between the labs and physical networks.
I quickly found that configuring the network connections, to meet my requirements, in Hyper-V over WiFi wasn’t so cut and dry nor was it documented well in one easy to read location.
I require the ability to run multiple, heterogeneous labs on a single laptop. These lab environments must be completely unaware of both one another as well as the physical network. The second big challenge is that I need all the computers in each lab to have Internet access. Each lab will have a domain controller, several member servers and a couple of clients.
I’d suggest that you first go through one or both of these two blogs which describe how to enable Server 2008 to be a workstation.
After you have the desktop experience installed and any customizations you’d like from the links above it’s time to enable Hyper-V and setup the required networking features within the host and guest operating systems. I disable the firewall and IE ESC before proceeding but that was covered in the blogs I linked to. If you followed the steps in the links above you should have already installed the wireless LAN service feature. If you have not already done so go ahead and enable wireless LAN service and install the Hyper-V role. There’s nothing special to do here, just run through the install roles wizard and select Hyper-V.
As I mentioned earlier my requirements may differ from yours. My goal is to run multiple labs on the same physical host. Those labs computers should not be aware of one another nor should they be aware of the physical network. However all lab computers must have Internet access. What I am about to describe works for this scenario. If your requirements differ this may not work for you.
1. Go to Hyper-V manager, open virtual network manager and add an internal virtual network. I called mine Internal VM Wifi and click OK.
2. Next create a private virtual network in network manager. I name mine according to the lab that will use this network. Each of my labs will use its own private virtual network so I perform this step once for each lab I intend to install.
3. On the host machine, in the Network and Sharing Center click on Change Adapter Settings. I suggest renaming the newly added adapter to something meaningful. I call mine Internal VM Wifi rather than the default network adapter #3.
4. Select both your WiFi adapter and the internal VM Wifi adapters by doing ctrl + click on each. Right click and select Bridge Connections
No more settings are required on the host machine at this time.
Go back to Hyper-V manager and create a new virtual machine.
1. The first virtual machine that should be created is the domain controller. This is the only machine that will need to connect to both the private network as well as the Internal VM Wifi network.
2. When I did this for the first time I didn’t add both networks prior to installing the OS. I came back later and added them and then the servers would not boot. Having said that I advise that you add both networks during the initial creation of the virtual machine prior to installing the OS.
3. During the new Virtual Machine Wizard add the Internal VM Wifi at the Configure Networking phase
4. After the virtual machine has been created right click the virtual machine in Hyper-V Manager and select settings.
5. On the Add Hardware page add a network adapter, select the private network created earlier and click OK.
6. Install a server OS on this virtual machine. This will become the domain controller, DHCP and DNS server for the lab network. I am using Server 2008 R2 so that’s what the remainder of this document is written based upon.
Perform the following high level steps on the newly installed Server 2008 R2 virtual machine. I’m not going into detail here how to build a domain controller, if you need that info you are in the wrong place.
1. Disable the Windows Firewall and IE ESC.
2. Verify that you can get to the internet.
3. Run ipconfig and note that one of your network connections has an IP address and the other does not. Remember which is which.
4. Open Control Panel>Network and Internet>Network Connections. By default the two network connections will be named Local Area Connection and Local Area Connection 2. If you are unsure which has an IP and which does not from step 2 above you can view the status of the connections. One will have Internet Access and the other will not. Rename the connection that has Internet access and an IP Address to External Network Connection and the other to Internal Network Connection
5. Assign a static IP to the Internal Network Connection. This IP will later be excluded from the scope you will create in DHCP after the server becomes a domain controller. I use 192.168.2.100. This address will also be the default gateway and the DNS server address.
6. Install the Active Directory domain service role.
7. Run dcpromo.exe to start the Active Directory Domain Services Installation Wizard which will also install DNS. Don’t worry about the message saying one network card has no static IP address. This is by design. The External Network Connection will never have a static IP, only the Internal Network Connection should have one.
8. Complete the Active Directory Domain Services Installation Wizard and reboot the computer.
9. Install the DHCP Server and the Network Policy and Access Services roles. You should only select Routing and Remote Access Services for the Network Policy and Access Services role. You should automatically see the Internal Network Connection as the only option that can be used to service DHCP clients. This is because it’s the only one that has a statically assigned IP Address. Use the IP you assigned this server as the IP address clients will use for name resolution. Setup a starting and ending IP address. I use 192.168.2.150-192.168.2.175 which leaves room for more servers to have static IP’s later. Enter the IP address that you assigned to this server as the default gateway that will be handed out to clients. Complete the wizard.
10. Open the Routing and Remote access snap-in. Select your server, right click and Configure and Enable Routing and Remote Access, select NAT. On the screen “Use this public interface to connect to the internet” select your External Network Connection.
This should complete the setup of your networking components. Install a new virtual machine, connect it to the private virtual network, join it to your domain, let it use DHCP and check your Internet connectivity.
If you want this environment to be even more portable install the “host” OS on a VHD using boot from VHD. This way the entire lab is contained within a single VHD file that you can boot from any Windows 7 or Server 2008 R2 physical machine.