Connect to SQL Server Instance on Virtual Machine from Host Machine Running Vista

by Ted Jardine Friday, July 27, 2007 5:26 PM

A couple months back when I first switched my primary developer machine to Vista, I wanted to connect to a SQL Server 2000 instance on my WinXP Pro virtual machine (Virtual PC 2007). It took a bit of digging to figure out how to a) even do it with WinXP to WinXP and then b) do it with Vista as the host OS.

Typically, it's an easy thing to set up your virtual machines to talk to each other, and also talk to the host machine, but to get the host machine to be able to talk to the virtual we need to go a little further by configuring a Microsoft Loopback Adapter. Using the Microsoft Loopback Adapter opens our Virtual Machine only to the host. To do this in Vista, do the following:

  1. Install a Loopback Adapter
    1. Open Control Panel
    2. Vista caveat: switch to Classic View to "Add Hardware"
    3. In the "Welcome to the Add Hardware Wizard", click Next.
    4. Select "Install the hardware that I manually select from a list (Advanced)" and click Next.
    5. Scroll down and select "Network adapters" and click Next.
    6. Select under Manufacturer "Microsoft" and then under Network Adapter "Microsoft Loopback Adapter" and click Next.
    7. Click Next and Finish.
  2. You can manually configure your IP Address for your adapter, but you can just let the loopback adapter get an auto configuration IP address from your router's DHCP.
  3. In your Virtual PC Console, choose settings for the applicable virtual machine, and then choose "Networking".
  4. Select the now available "Microsoft Loopback Adapter" (note that your virtual machine will need to be off, not in a saved state, in order to make this change).
  5. Turn on your virtual machine and once it's booted up, verify that the Microsoft Loopback Adapter has installed its routing in your host PC's route table by going to a command prompt in the virtual machine and typing "route print".
  6. In the case of a virtual machine running WinXP, make sure you've allowed file and print sharing in the virtual machine's firewall settings.
  7. Open a command prompt and run ipconfig to find out what your virtual machine's IP address is (note that as we have not configured the Microsoft Loopback Adapter to allow the virtual machine to connect to the outside network, your task bar network icon will warn you that you have limited connectivity – thus the need to run ipconfig from a command line to see if the virtual machine even has an IP address assigned).
  8. Check whether your host machine can now communicate with the client virtual machine by pinging it's IP address by opening a command prompt in Vista and typing "ping 169.254.166.12" where you enter your applicable IP address.
    c:\>ping 169.254.166.12
    Pinging 169.254.166.12 with 32 bytes of data:
    Reply from 169.254.166.12: bytes=32 time=1ms TTL=128
    Reply from 169.254.166.12: bytes=32 time<1ms TTL=128
    Reply from 169.254.166.12: bytes=32 time<1ms TTL=128
    Reply from 169.254.166.12: bytes=32 time<1ms TTL=128
    Ping statistics for 169.254.166.12:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms
  9. And voila, you've now successfully networked your host machine to talk with your client virtual machine.

If you still want internet access for your client virtual machine, do the following:

  1. Open your Network and Sharing Center
  2. Click Manage network connections in the left hand navigation bar
  3. Right-click the loopback connection and select properties.
  4. In the sharing tab, enable “Allow other network users to connect through this computer's Internet connection.

This "should" work, but I initially encountered "an error occurred while Internet Connection Sharing was being enabled." However, it resolved soon afterwards all by itself.

The article that was the biggest help in getting the above in place was http://www.governmentsecurity.org/archive/t10129.html

UPDATE: Change to post title.

blog comments powered by Disqus

Month List