Configuring Virtual PCs' network adapters can be confusing. If you think about it, you're taking a network card, which typically has one IP address and one MAC address, and making it work for two computers. Add to that security issues - you may not always want a virtual pc getting out over your network- and things get complex quickly. Recently, though, I wanted to set up a SharePoint demo on a virtual machine, and wanted a setup that:
- Allowed my host pc to connect to the web server on the virtual pc.
- Allowed the virtual pc to connect to the internet.
- Allowed the virtual pc to connect to my host pc
After a little digging, I came across this post on Ben Armstrong's blog that spelled out how to install the 'Microsoft Loopback Adapter' and wire it up to a host network adapter. It worked as advertised, but I had to reboot and forgot to set the loopback adapter in the virtual machine network settings. In retrospect, both pretty obvious steps, but, for posterity, here are full instructions for the above scenario (Most of these are straight from his post - be sure to check his blog out for much more Virtual PC info):
Install Microsoft Loopback Adapter:
- On the host operating system go to 'Control Panel'
- Go to 'Add Hardware'
- In the 'Add Hardware' wizard, click 'Next'
- When the 'Is the hardware connected?' page appears, select 'Yes, I have already connected the hardware', and then click 'Next'
- In the 'Installed hardware' list, select 'Add a new hardware device' and then click 'Next'
- In the 'What do you want the wizard to do?' list, select 'Install the hardware that I manually select from a list (Advanced)', and then click 'Next'
- In the 'Common hardware types' list, click 'Network adapters', and then click 'Next'
- In 'Manufacturer' list, select 'Microsoft'
- In the 'Network Adapter' list, select 'Microsoft Loopback Adapter', and then click 'Next' twice
- In the 'Completing the Add Hardware Wizard' page, click 'Finish'
Turn Internet Connection Sharing on, on the adapter that you want to share, NOT on the loopback adapter. Typically this is your Wifi or LAN adapter.
- On the host operating system go to 'Control Panel'
- Go to 'Network Connections'
- Right click on the network connection that you use for Internet connectivity and select 'Properties'
- Click on the 'Advanced' tab
- Check the option to 'Allow other network users to connect through this computer's Internet connection'
- If you have multiple network adapters you will need to also specify that you are sharing the Internet connection with the Microsoft Loopback Adapter.
- Click 'OK'
At this point, I had to reboot. Your mileage may vary.
Finally, in the virtual machine's settings, change the network adapter to use the loopback adapter:
- In Virtual PC, go to Settings -> Networking for the machine
- Set Adapter 1 to 'Microsoft Loopback Adapter'
- Click 'OK'