Sometimes I need to replicate customer issues in a Hyper-V lab to fully understand and fix the problem. My labs are typically pretty small and disposable - I set them up for a specific purpose and then trash them. For this reason I use Windows 8 Hyper-V running locally on my laptop. This was working great for me until recently when I needed to replicate a customer problem involving a specific site/subnet configuration. I wanted a way to route between subnets within my Hyper-V lab.
This is a quick and painless guide to quickly set yourself up a software-based router (Windows 2008R2 Routing and Remote Access) to route traffic between subnets in your Hyper-V lab. There may be other methods out there but this works for me.
1. Set up your lab as normal. I’m going to use the diagram below for my example. The goal is to route traffic from Network A to Network B and back the other way.
2. Create a new VM in Hyper-V. Name it something obvious like “Router”. Allocate at least 512MB RAM and 10GB Storage.
3. Give it a second Network Adapter. In the settings for the “Router” VM, click “Add hardware-> Network Adapter->Add”.
Ensure both of your network adapters are connected to the same Hyper-V Network. In my diagram below, you’ll see I’m using a virtual network called “Private Switch”.
4. Install Windows Server 2008 R2 on the “Router” VM.
5. In Server manager, Install the “Network Policy and Access Services” Role, Followed by “Routing and Remote Access Services”
6. Configure your two Network Interfaces on the “Router” VM.
Network A (NIC1)
Network B (NIC2)
IP Address: 192.168.0.1
Subnet Mask: 255.255.255.0
Default Gateway: blank
DNS Server: blank
IP Address: 192.168.1.1
7. In Server Manager, Right click “Routing and Remote Access” and select “Configure and Enable Routing and Remote Access”
8. Select “Secure connection between two private networks”. Select “No” then “finish”
9. Your Windows router is now set up!
Now you just have to set the default gateway for the rest of the machines in your lab (by using DHCP options or static configuration).
Network A – Default gateway of 192.168.0.1
Network B – Default gateway of 192.168.1.1
Clients in Network A can now be routed to Network B and vice-versa. Use Ping to test it works.