Sunday, April 4, 2010

MOSS 2007 development environment - VMWare network setup

Virtualized server environments now-a-days have made the life of a software engineer comfortable, due to the fact that running two or three servers and testing a client app on same laptop has given us the near-ideal scenario on software testing and debugging. Not only for MOSS, any kind of client-server multi-tier development can be benefitted equally with this approach.

Running a virtual server (VMWare, Virtual PC, Xen or anything else) on laptop has become mundane and more powerful hardware releases and prices of memory falling down day by day, software development and testing on virtualized environment is now becoming mandatory part of a developer’s daily life.

If the laptop (or desktop) is connected to a fixed network (LAN), then the default installation of VMWare (or anything else) mostly works out of the box. Any novice can do it and get the hang of it in no time. There are plenty of blogs, guides and video tutorials available on youtube to help you through the quite simple process. However, using a laptop as the development environment, running multiple virtualized servers, has a set of requirements, which is not commonly applicable for desktop based development. One, most obvious is the connectivity. For a laptop, it is to be used on-the-go, on different networks, with multiple networks (LAN, wireless, HSDPA etc.) and in a considerable time without a network connection at all.

The problem:
  1. Since my dev machine is a laptop, I move from a network to another
  2. Don't have a static IP for the Host. Cannot have this when on wireless on-the-go
  3. I must have static IP for the guest since it runs MOSS. (and another guest runs AD and SQL Server.
  4. Host should be able to talk to the guest on static IP. I use vhost file, so convenient names can be used to access servers.
  5. Guest should be able to access internet. This is critical, since sometimes I need to use a browser on a guest to check various things on internet, without switching back to host.
  6. Nevertheless, all these requirement should not compromise the Host’s ability to access internet as well as the network resources where applicable.
  7. Last but not least, I should be able to communicate between host and guest, even without I am not connected to a physical network.
I need all of these to be achieved, without compromising any other. So I am talking about ultimate luxury in Virtual development environment, sounds too demanding…. well probably yes but I won’t settle for less…
VMware’s built in networking options (bridged, Nat, Host only) satisfies some requirements but not all. Same goes with Loopback adopter method. So was in a quest to find a perfect-solution for me… ofcourse.
My Solution (I just found this my way, but probably many others brighter than me would have found this numerous times earlier, so expecting no credit..) -

The Solution:
It found to be too simple to believe. Yes way too simple, and uses VMWare’s built in NAT networking method. Just follow these tiny steps which leaps you forward.
  1. Set guest to use NAT (go to network adopter for the guest, and change its properties to use NAT
  2. In the ‘Virtual Networking Editor’ (workstation>Edit>virtual network editor), select VMNet8 (which is for NAT).
  3. Note the DHCP IP range. Choose a convenient IP from the range, and you will be using this for the guest (s) later. You may chose to change this also, but that is totally up to you.
  4. Click on the “NAT Settings” button and note the default gateway IP presented. You may chose to change this also.
  5. Only thing left now is to set the guest’s network to use the chosen static IP and the gateway IP.
Unless you chose to change the default IPs and know what you are doing, this only requires very minor settings (Change VM network to use NAT, set guest IP and Gateway), no pain, no wait.