Friday, November 5, 2010

Set Up Hyper-V With an Internal Network

Hyper-V is Microsoft's server virtualization product. Unlike Windows 7's Virtual PC, this product is a true vitalization suite. It allows you to create 32bit and 64bit virtual computers with any OS. This makes it very handy to create a virtual server farm for development or R&D use. Personally I use mine to host development environments for SharePoint 2010, and MOSS 2007.
If you want to create virtual servers that are available on your current network, simply attach your network card to the VM and off you go(more on this later), BUT if you want a private network separate from your public net work, i.e. you want to create a separate domain for testing and dev work, but want to keep your workstation connected to your current domain, it gets a little tricky.
I did my configuration using RRAS, not ICS. For one, RRAS is much more flexible than ICS, for another, RRAS is the professional way to do such a configuration. And I am always the professional. Like that guy in the movie Professional... Except I don't kill people... and I have friends other than a plant... and I don't have a French accent... and I am not being chased by Garry Oldman... and I don't live in New York... Other than that it is just like the movie.

Install Hyper-V
Hyper-V is a Role that you need to add to your host server. So, open your old friend Server Manager and head to the Server Roles section. Check Hyper-V and install.

Configure Networking
Now things get fun. In Hyper-V Manager, click on Virtual Network Manager. Create a new Internal network and give it a meaningful name. That name will become very important, so be sure to name it well. I called mine Hyper-V Internal Network.

What Microsoft has done with Hyper-V is to separate the physical network card completely from the OS. It then creates a virtual switch with several virtual network adapters connected to it. This is kind of complex, and you can go HERE if you want to learn more. What concerns us here is what happens with the Host's network adapters.
Open up Network Sharing Center, then click on Change Adapter Settings. You will notice that there is a new icon there. It will say something like Local Area Connection 2 or some other number. What is important is that the last line in the description, the binding information, should be the name that you gave your virtual network back in the Hyper-V manager.

Configure the Host's Virtual Network Adapter
Right click on the icon representing the Hyper-V virtual network adapter and select Properties. Double click on the v4 network settings.
Setting up the Host adapter is kind of funky compared to normal network set ups. First of all, we will not be putting in a gateway address. The virtual switch will be the gate, and if we specify a gate here, it screws everything up. In addition to this, we will not be putting in any DNS IPs either. Again, the switch will act as the DNS relay. The only thing we need to put in this area is the IP address and mask of the Host on the internal network. This address must be on a different subnet than the subnet that the host is on for the public network.
It makes sense if you think about it. Essentially, you are configuring your server to be a router. Routers need two network cards and need to have each card on a different subnet. Since you are creating a private VLAN, you will need some sort of router or switch to get you to other networks, thus the separate subnets.
So, my public network is, 192.168.107.x, I made my internal network 192.168.2.x.
To reiterate, on the HOST, the virtual adapter settings should just be the IP address and mask of the HOST in the subnet of the internal network.
In my set up my IP is 192.168.2.1, subnet 255.255.255.0.

Install RRAS
Back to the Server Manager for another role install. This time it is the Network Policies and Access Services role. Check that, then select Routing and Remote Access Service. Be sure both boxes underneath the selection are checked. Unless you are familiar with access restrictions, DO NOT install the Network Policy Server. This can mess up your installation if you don't know what you are doing. I didn't need this service, so I did not install it.

Configure RRAS
From here you will click on the new role that you installed (Network Policies and Remote Access) and right click on Routing and Remote Access. Select Configure. We are going to create a policy for NAT, so that is the guy we select. The next screen deals with which interface has the Internet. Select your public network interface and select next. Now we select the interface that we want to NAT on. Select the internal Hyper-V interface. That completes the initial configuration. We still have to configure NAT. You thought you were done with that, but you are not!

Configure NAT
Open up RRAS, then IPv4. Click on NAT. Right click on your public interface and select Properties. Click the radio button that says Public interface connected to the Internet. Check the box that said Enable NAT on this interface.
From there go to the Services and Ports tab. Check the box for the the various services that you want to use NAT for. I just want Internet, so I checked Secure Web Server(HTTPS), and Web Server(HTTP). When you check the boxes it will ask you what IP address you want to NAT from. Put in your interface IP address (for me that was 192.168.2.1). Click OK.
Done!

Install VM
From here You want to create your first Virtual Server. Set this up how ever you like it according to your needs. The network adapter that you want to use will be the name of your internal network.
When your OS is done installing, you will notice that it will have an IP address if you have enabled DHCP. This comes from the RRAS server. If you want a static, simply put in your address and mask from the internal network subnet. Your gate will be the Host interface, as will be your DNS servers.

DONE!

No comments:

Post a Comment