Hyper-V Networking Set up
Recently I decided to make the long outstanding change from VMWare to Hyper-V as a development environment using Windows 8.1, after all it made sense to try it out! Installing Hyper-V with Windows 8 was dead simple, turn on the feature in Programs and Features, reboot the machine and you're done... make sure you have virtualization enabled in your BIOS of course.
This post should give you a quick walk-through of the set-up process. I have created a domain controller of which I do not want to have internet access or to be able to communicate with the network outside of the host. Then I created servers which I do want to have internet access, but still be able to talk to the domain controller. This environment in particular is a Dynamics CRM server set-up, however this will work for any windows server's and the set-up process is the same.
Environment:
- Internal Virtual Switch (192.168.10.2)
- External Virtual Switch
- Domain controller (DC01 / 192.168.10.10)
- CRM Server (CRM01 / 192.168.10.20)
- SQL Server (SQL01 / 192.168.10.30)
Great! so now you have Hyper-V installed what next?... Create VMs right?
This is where I came a little unstuck with the standard Hyper-V set-up. Now you need to create a virtual switch for your virtual machines to talk to, but maybe like me you only want certain VMs to communicate out to the internet, whilst still being able to RDP to all VMs from the host. Some people to achieve this take the approach of turning the host machine into a domain controller, to me this does not seem practical and of course, there is always an easier solution.
Virtual Switches
So first things first! We need to sort out our virtual switches, one for internal communication on the V-LAN and the other for external communication out to the internet.
Once you have loaded up the Hyper-V Manager console you should see the Virtual Switch Manager in the right hand pane, in here you will be able to create the two needed switches, an internal switch and an external.
The external switch will need to be assigned to your physical NIC in the host machine as so:
The internal switch will look like the below:
Once you have created these virtual switches, you should see them listed as adapters on your host machine. Now we need to give the Internal Switch adapter a static IP, for this example I have used the following IP address: 192.168.10.2. You can leave the default gateway and DNS Servers blank, as this is just an internal V-LAN.
Our virtual switches should now be all set-up, the external switch requires no static IP, this will just act as the gateway to the internet.
Virtual Machines!
Now we have got our virtual switches all set-up, it's time to create our virtual machines. Now in this example I am using Windows Server 2008 R2 as the server OS but the principal is the same in Server 2012
Domain Controller
First is the domain controller. Now this server I do not want to be able to communicate out to the internet and the network outside of my host machine. This server should only talk across the V-LAN.
To achieve this we only assign one network adapter to the VM, which is connected to the internal switch:
Once logged onto the domain controller we assign it a static IP, I have pointed the DNS at itself (local loopback) as this server will run the DNS role as well:
Servers (CRM, SharePoint, anything not a domain controller!)
Domain controller up and running, now ready for the rest! The rest of my servers I do want to be able to connect to the internet for windows updates and things like making the install process for CRM a lot easier.
In order for this to happen the VM will need to have two virtual network adapters assigned to it, one connected to the internal network and the other connected to the external network, this is shown below for my CRM server:
Now that you have these connected, like the domain controller, we can assign a static IP to the adapter connected to the internal switch. If you cannot recognise what adapter is connected to what switch go back and disconnect the external adapter for a moment while we assign the IP. For my CRM server I have given this the following IP: 192.168.10.20
Note: As seen in the screenshot above, I have set the DNS server to be the IP address of the domain controller (as it runs the DNS role). This is important for joining the server to the domain, and also finding other servers in the domain. If you have not installed DNS on your domain controller then you will need to point the DNS at your DNS server. You can also add the host name and FQDN of the domain controller to the servers host file.
Now your server should be set-up to communicate with other virtual machines on the internal switch and also out to the internet via the external switch.
RDP from Host
One final change I made was to my host file on my Windows 8.1 host Hyper-V machine. In order to RDP to the servers on the internal switch, the IP address would have to be used. This is because the Hyper-V host does not use the domain controller VM for it's DNS, in my case the host looks at Google DNS as my preference.
To resolve this issue the hostname, FQDN and IP of the servers needs to be added to the host file located here:
C:\Windows\System32\drivers\etc\hosts
Note: When editing the host file, ensure you are running notepad with elevated privileges in order to save the system file back to it's original location.
Now the development environment should be all set-up, you can repeat the "Servers" process assigning static IPs and DNS to any more servers you create and joining them to your domain.
No comments:
Post a Comment
Comments, thoughts, questions...?