Those of us who use Hyper-V for development know of the challenge we face when we try to copy files or talk to the guest virtual machine or have the guest VM access the host machine. It’s frustrating because it was so easy to do in VirtualPC or VMWare Workstation as we had the easy copy files to and from the desktop just like we can do with Remote Desktop.
There is a way around this though… it’s a simple networking trick. Now, I’m a bit of a networking-idiot and had to get Todd Baginski and Maurice Prather to help me with this (so big shout out to them), but it’s actually quite simple and I after explaining it to to quite a few people, I’m documenting it so I have a URL to point to where others can do it on their own. Hopefully this helps you.
Overview
Basically what you’re going to do is create a new virtual network on your Hyper-V machine, add a new NIC to your VMs and then put them on the same network.
Step 1 – Create a new virtual network
The first thing you need to do is create a new virtual network. From within Hyper-V, select Virtual Network Settings. Create a new INTERNAL network and leave all the default options. I like to call my virtual network INTERNAL.
What this does is create a new network within Hyper-V and creates a virtual NIC adapter on the host machine.
Step 2 – Configure the NIC on the host machine
With the virtual NIC created on the host, you want to change his IP settings. I put mine on a network I know I never use:
- IP: 192.168.1.20
- Subnet: 255.255.255.0
Leave everything else blank / default. The other thing I do is rename this NIC adapter to Hyper-V INTERNAL to make it easy to find later.
At this point the host machine is set up and ready for action!
Step 3 – Add a new NIC on the guest machine
Now it’s time to set up the guest. First, shut down the guest machine so that it’s not running or in a saved state.
Then, modify the settings of the virtual machine (right-click the virtual machine and pick settings). In the settings dialog select Add New Hardware at the top of the left-panel and select the network you created in step 1 above. Leave all settings as the default options.
With a NIC added to the VM, start the VM up.
Step 4 – Configure NIC on the VM
When the VM is turned on, you can now configure the new network adapter. Change his IP settings to put him on the same subnet but with a different IP than the host. For instance:
- IP: 192.168.1.21
- Subnet: 255.255.255.0
Again, leave everything else blank. Also, just as above, I like to rename this NIC to make it easier to find in the future.
Step 5 – Test file access & RDP
Now you’re likely good to go! There are two ways I utilize this:
- File system – from either machine you open Windows Explorer and type
\192.168.1.[###]\C$
where the[###]
is the IP of the machine you’re trying to reach. Be patient as it can take a minute to come back and prompt you for credentials. - Remote Desktop – this is my preferred way of working with the VMs. From the host I use Remote Desktop, connecting using the IP we added to the VM, to get a full screen mode with richer copy/paste between the host and the guest OS.
Hope this helps someone!