Wednesday, May 18, 2016

Hyper-V - Internal Network with Internet Access

So one of the big things I wanted to do with my new lab is make sure that the servers have internet access. I wanted SCOM to be able to send notification email's and SCCM to access updates as well as other things I am planning for future expansion. I am using Hyper-V which comes free with Windows 10 Enterprise so I needed a way to do this simply and effectively. As it turns out there is a way. You can configure the Host network adapter to share its connection with a Hyper-V virtual switch and pass that connection to the guests.

First thing you do is go into Hyper-V and create a new Virtual Switch. Click on Virtual Switch Manager, select Internal and Click Create Virtual Switch.

For the Virtual Switch Properties give it an easily identifiable name. I called mine Hyper-V Internal (w/ Internet). Maker sure Internal Network is selected and Click OK

Now that we have the virtual switch created:

Next we need to enable Routing and Remote Access. On the Host machine open up services and find Routing and Remote Access. You will see that it is Disabled. Open Properties, change the startup type to Automatic (Delayed Start) and apply. Then Start the service and hit OK.

Now we need to setup the network sharing. On the host machine open up Network and Sharing Center. You should see your newly created Virtual Switch:

If you open the connection status of the Virtual Switch, go to Properties, scroll down to Internet Protocol Version 4 and check the properties there you will see that the virtual switch has been given an IP address of 192.168.137.1. This is important so we will come back to this in just a second. 

Now you want to open the network connection for the host. In my case it is the Wi-Fi connection. In Wi-Fi Status select Properties. In Wi-Fi Properties click the Sharing Tab:

In Internet Connection Sharing check the box Allow other network users to connect through this computer's Internet Connection. In the dropdown select the newly created Virtual Switch and Click OK.

All that is left to do is assign the network connection to the VM guests in Hyper-V. Right click on the VM and select Settings. In the Settings for your VM click on Network Adapter. In the virtual switch  select the newly created Virtual switch and click OK

Now for most servers you want to set up a static IP address. Even though DHCP is currently being handled by your internet router you will want to change this to static for servers. Since our Virtual Switch has an IP of 192.168.137.1 we will need to set the static IP of the guest VM to the same subnet. In my case the first machine I setup was the domain controller so I setup like the following:
The Default Gateway must be set to the IP address of the Virtual Switch (192.168.137.1). Also I have DNS setup on my domain controller so it points to itself. All of the subsequent VM guests will need to have the same subnet, default gateway and DNS.

Note -  The IP address assigned to the Virtual Switch is more or less randomly assigned. You do not need to keep it 192.168.137.1. It can be changed to whatever you would like in your environment. Just remember to use the new address as the default gateway for your servers and they all must be on the same subnet.   

From here you can test by pinging google.com

All Set!

More to come!

If you like this blog, give it a g+1

1 comment: