Using The Loopback Adapter and SharePoint

Just a little tip as I've recieved a lot of emails and questions about SharePoint development recently. Most SharePoint development is going to take place in a virtual machine (unless you're running Server 2008 as your desktop, which isn't hard. Check out win2008workstation.com for some great tips on this). A lot of people simply run their virtual machine natively, using the VM client. This is okay but it requires you to be logged into the machine (usually as an administrator) and you have to contend with multiple accounts (and keeping track of what account you're using), IE issues, etc. Add to the fact you want to say check out your site with Firefox or do some debugging with Fiddler and you're installing and loading up the server image with additional software (so your VM image grows and grows and grows, much like a developers belly).

Just say NO to doing this. Everything you need (other than local development with Visual Studio, although that can be accomplished too) can be done from your host OS desktop. It's really easy. You just need to add and configure the Microsoft Loopback Adapter on each machine and give it an IP address. The loopback adapter is just a dummy driver, no hardware needed, that simulates a network adapter. It's a great tool for testing in a virtual network environment where network access isn't available and really you don't want to be exposing your VMs to the Internet unless absolutely necessary (maybe for monthly image updates, but even then I try to do this locally).

Here's how to configure your network for SharePoint development:

Server

On the server (Server 2003), you'll add the loopback adapter as new hardware.

  1. Go to Control Panel -> Add Hardware
  2. Click Next on the first page of the Add Hardware Wizard
  3. The system will search for new hardware. Select "Yes, I have already connected the hardware" from the options and click Next
  4. Scroll to the end of the hardware list and select "Add a new hardware device" and click Next
  5. On the next page select "Install the hardware that I manually select from a list" and click Next
  6. Select "Network adapters" from the list of hardware types and click Next
  7. Under the Manufacturer list select "Microsoft" and under Network Adapter select "Microsoft Loopback Adapter" and click Next
  8. Click Next to install the hardware

Once the loopback adapter is installed we want to configure it with a static IP address. For Domain Controllers you have to use a static IP and it's a good thing so we know where machines are and can easily access them by name from our clients.

Under the Control Panel -> Network Connections you'll see a new network adapter (usually called "Local Area Connection").

  1. Right click on it and select Properties.
  2. From the Properties dialog under the General tab select Internet Protocol (TCP/IP) and click Properties.
  3. Change the General settings to "Use the following IP address" from "Obtain an IP address dynamically"
  4. Enter a fixed number using 10.* or 192.*. I generally use 10.* for my virtual networks so they don't collide with my desktop and automatic ones. 10.50.50.1 is a good choice. Make note of this number for later.
  5. Enter 255.255.255.0 for the subnet mask
  6. Leave the gateway blank (as this machine is the gateway)
  7. I use 127.0.0.1 for the Preferred DNS server listed on this dialog. This means the server doesn't try to go out to the network to resolve any names which is good for development.
  8. Click OK to close the dialog.

Client

With the server setup we need to configure the client. On the client OS follow the same steps as the server configuration above.

  1. Go to Control Panel -> Add Hardware
  2. Click Next on the first page of the Add Hardware Wizard
  3. The system will search for new hardware. Select "Yes, I have already connected the hardware" from the options and click Next
  4. Scroll to the end of the hardware list and select "Add a new hardware device" and click Next
  5. On the next page select "Install the hardware that I manually select from a list" and click Next
  6. Select "Network adapters" from the list of hardware types and click Next
  7. Under the Manufacturer list select "Microsoft" and under Network Adapter select "Microsoft Loopback Adapter" and click Next
  8. Click Next to install the hardware

Once the adapter is installed reconfigure it like above but give it a client IP that's in the same subnet as your server you setup above.

  1. Under the Control Panel -> Network Connections select the new Loopback Adapter.
  2. Right click on it and select Properties.
  3. From the Properties dialog under the General tab select Internet Protocol (TCP/IP) and click Properties.
  4. Change the General settings to "Use the following IP address" from "Obtain an IP address dynamically"
  5. Enter a fixed IP in the same subnet as your server. In our example, the server is at 10.50.50.1 so make the client 10.50.50.100 (use 100 as the starting IP for any client machine).
  6. Enter 255.255.255.0 for the subnet mask
  7. Enter 10.50.50.1 for the gateway.
  8. Leave the DNS entries blank.
  9. Click OK to close the dialog.

Finally on either client you'll want to create a named alias to your server in your local hosts file. This makes for accessing the server by name rather than IP and lets you use host headers on your server (something you'll want to do when you setup things like My Sites, it's preferred to use host headers over server names as you can setup multiple sites on the same server).

To update your hosts file:

  1. Navigate to your Windows directory (usually C:\Windows)
  2. Go into the system32\drivers\etc folder
  3. Edit a file called HOSTS
  4. Add an entry at the end with 10.50.50.1 as the IP address (press TAB) then enter your server name (in my example, litwaredemo)
  5. Save the file

Virtual Machine

Finally, once the loopback adapter is installed on your host OS you can reconfigure your virtual machine to use it. This can be done while the machine is running. Go into the settings (on Virtual PC it's the Settings button or Action -> Settings menu when the VM is highlighted) and select Networking. From there pick the Microsoft Loopback Adapter for the adapter.

To do a test, try to ping the server from the client. Open a command prompt and type:

ping 10.50.50.1

(substituting the IP address you used in step #4 in the second part of the server setup above). 

You should get a response. If not, go back and check the server and client to make sure all your IPs and subnet masks are set correctly and that the server shows connectivity.

Once that's setup, open up whatever browser you want from your desktop and browse to your server name (in this example, http://litewaredemo) and go nuts. Also if you need to perform some maintenance on the system, get into Central Admin, or whatever just use the Remote Desktop client from your host OS. It's actually much faster than using the native client and you can allow it to access local resources (like a downloads directory) so again, you don't have to clutter up your VM with downloaded files and applications you don't need.

If you create multiple sites on your VM to try out different features, layouts, etc. just create a new website and give it a host header (dev1, MyMotherTheCar, AReallyLongServerNameThatWouldBeHardToTypeInEachTime, whatever). Add this entry to your local HOSTS file on your client and fire up your browser. Easy sleazy.

Enjoy!

6 Comments

  • When your VS development is tied to source control, with this configuration you cannot connect to Source safe/TFS right? or is there a way?

  • Nice! Thanks for doing this -- I mucked around with this for too long, it's good to have it documented!

  • Hi,

    Did you consider using ICS's BIND on Vista for DNS server? This way all your applications could benefit real DNS adressing, especially when one has a reserved DNS domain.

  • Thanks a lot. The loop back adapter solutin really helped me out.

  • This works brilliantly. Many thanks. I do have one question though. Am I correct that this will only work when SharePoint users are all local accounts on the guest machine?

    My host machine is attached to my Active Directory. When I try to log into a site using an AD account, I get the error "No authority could be contacted for authentication"

  • hi, tried it all. my client is win7..did not work. both machines cient and server dont recognize the ping...

Comments have been disabled for this content.