2007.02.04...6:49 pm

Virtual PC IP Routing: enabling VPC NAT & loopback connector at the same time

Jump to Comments

Well it took me about two days, but I finally was able to get my virtual pc networking configuration setup the way I want. My desire was to have the following abilities:
1. Host system access to the Internet
2. Guest system access to the Internet
3. Host system access to the Guest via a virtual “”domain name”"
4. Guest system access to the Host via a virtual “”domain name”"
5. Did not want to enable Internet Connection Sharing on the host.

In the end I was able to make this work by doing the following:
1. Install the MS loopback network adaptor on the Host system
2. Set up two network connections for the Guest OS (In the virtual pc settings), Adapter 1 is set as the Shared networking (NAT) adapter, Adapter 2 is set as the Microsoft Loopback Adapter.
3. On the host system set the loopback adapter TCP/IP settings to use the address 172.16.16.2 (Subnet mask: 255.255.255.0 with NO default gateway or DNS servers)
4. On the guest system set the loopback adapter (adapter 2) TCP/IP settings to use the address 172.16.16.4 (Subnet mask: 255.255.255.0 with NO default gateway or DNS servers)
5. On the host system add a static persistent route to the IP routing table. Here is the command:
route –P add 172.16.16.4 mask 255.255.255.255 172.16.16.2 metric 1
6. On the host system edit the hosts file (C:\WINDOWS\system32\drivers\etc\hosts) and add a host name for the IP address, add the following line
172.16.16.4 localserver
7. Repeat the last two steps (5 & 6) on the guest but substitute the IP of the host and set the name to hostpc

There you go. With this set up, I can now access the guest machine from the host as “”localserver”" and the host from the guest as “”hostpc”". Both installations also have access to the internet. Naturally any set of private ip addresses can be substituted in the example … but do not use the link-local address range (169.254.x.x)

7 Comments

  • I had some issues with your routing table command.

    You have a typo in the gateway IP – 2.16.16.2 should be 172.16.16.2.

    Also, I was unable to get the command to run unless the -p parameter is passed as the last item:

    route ADD 172.16.16.2 MASK 255.255.255.255 172.16.16.4 METRIC 1 -p

    Typos aside… thanks for the article and saving me a bunch of time trying to figure this out on my own!

  • One point that was at first unclear to me: After setting up the loopback adapter on the host (instructions for doing so here), the host system’s loopback connector will appear in the guest system’s network connections list as another generic ethernet adapter. Configure *that* adapter to 172.16.16.4, if it doesn’t default to that setting.

  • Thanks for the great info.

    What would you do if you wanted to limit the virtual pc to only be able to see the host machine, and not the internet as a whole (e.g. to basically use the virtual pc os as an IE6 testing virtual machine only).

    Thanks.

  • Thank you for posting this!

    After trying three or four different solutions found on other blogs to no avail, I eventually was able to get a ping to work using your method.

    ( I am running Windows 7 with a virtual XP SP 3 )

    I then found that the windows firewall was blocking HTTP connections between the host and the vitual machine, once this was fixed, hey presto it worked!

    Thanks again,

    Chris

  • Anthony Rodriguez

    This is a great post. Tried your tips and it worked exactly as you described. Nice work.n

  • What’s the command to UNDO the “route –P add 172.16.16.4 mask 255.255.255.255 172.16.16.2 metric 1″ command ?

    Thanks,
    EDH

    • You would just replace the word ‘add’ with ‘delete’ actually I think you just have to put the IP so it would be route DELETE 172.16.16.4 if you run the command route -? you will get the help file for the route command.


Leave a Reply