If you want to create a network between the host and VM using Windows Virtual PC in Windows 7 then this guide is for you. This is especially useful if you need to communicate with the VM when not connected to a network. WVPC offers a number of networking options:
- None – no networking
- Internal Network – Network between hosted VMs (but not the host)
- NAT – Sets up a virtual NAT to allow the VM to access the internet
- Bridge – Allows the VM to use one of the hosts network adapters to access the local network
I do all my work from my laptop, including hosting my VM so at home, when connected to my home network (LAN) i use the bridged mode – my laptop connects using the wireless adapter and the VM uses the Ethernet adapter. This way i can see both the host (laptop) and VM on the network and they can talk to each other great. The problem arises when i am travelling and not connected to a network – in this scenario bridged mode is no use because there is no network for the VM and laptop to communicate to each other. What I want is a ‘host-only’ network mode, similar to what VMWare offers. The following steps allow you to set up a local bridged network that allows the two to communicate on a private network:
Setup a loopback adapter on the Windows 7 host
- In the start menu type command, right-click Command Prompt and select Run As Administrator to open a command window with administrator privileges
- Type hdwwiz and press enter to start the Add Hardware Wizard
- Click Next
- Select Install the hardware that i manually select from a list (Advanced) and click Next
- Select Network Adapters from the list and click Next
- Select Microsoft in the Manufacturers list and then select Microsoft Loopback Adapter in the Network Adapter list and then click Next
- Click Next to install the loopback adapter
See here for the above instructions including images of each step.
Configure the loopback adapter
- Go to the Network & Sharing Centre (from the start menu)
- Click Change Adapter Settings from the list on the left
- Go to the properties of the Microsoft Loopback Adapter
- Disable all items, except Client For Microsoft Networks, Virtual PC Network Filter Driver and Internet Protocol Version 4 (TCP/IPv4). If the Virtual PC Network Filter Driver is not enabled, the VM will not see the adapter
- Go to the properties of the IPv4 protocol and set the IP to a reserved private IP, such as 192.168.x.x or 10.x.x.x, that does not conflict with any other network you will connect to. Ensure that the gateway is left BLANK otherwise it may cause issues with other networking
- Click OK until the dialogs are all closed
- Open regedit and browse to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}
- Find the subkey (0001 … 00xx) that corresponds to the loopback adapter (DriverDesc = Microsoft Loopback Adapter)
- Add a DWORD called *NdisDeviceType (don’t forget the asterisk at the start) with a value of 1
- Go to the start menu and type View Network Connections to open the list of network adapters
- Disable then enable the Microsoft Loopback Adapter to apply the registry changes. The loopback adapter will no longer appear in the Network and Sharing Centre but will operate as a network endpoint on a private network, which is exactly what we want. See here for more information.
See here for a thread discussing the registry change
Configure the VM to use the loopback adapter
- Ensure the VM is shutdown (not hibernated) to simplify the following steps
- Right click the virtual machine .vhd file and select Settings
- Change the network adapter to use the new loopback adapter (if you cant see it in the list, check that the filter driver mentioned above is definitely enabled on the host)
- Save the settings and run ipconfig from the command-line to check the IP has been successfully set
- Start the VM
Configure the loopback adapter in the VM
- Go to the properties of the Local Area Network connection in the VM
- Go to the properties of the IPv4 protocol and use an IP on the same subnet as the host (eg if the host is 192.168.1.1, use 192.168.1.2 for the VM)
- Save the settings and run ipconfig from the command-line to check the IP has been successfully set
Note that pinging does not appear to work using this configuration, even when IP addresses are specified. However i have been able to successfully perform all other network operations without problem. The drawbacks with this approach are that the VM cannot communicate to the hosts network when it is connected. In this scenario, either change the VM to bridge via a different, connected adapter on the host as outlined above, or setup a proxy on the host that can forward requests from the VM to the network.