UPDATE: The contents of this post are a hack for static IP addresses… I’ve posted a better way here.
A while back, I wrote about the benefits of using cross-platform tools (when available) for software development. The Bottom Line: it allows developers to more easily make the transition to other platforms and new languages. The practice enables developers to use tools they are already familiar with without having to assume the overhead of learning a completely new set of tools along with the new platform or language. So in the spirit of drinking my own Kool-Aid, I’ve recently made the transition from VMWare Fusion to VirtualBox to power my back end SQL Server VM required for our Rails project. Following are the setup details in case anyone else out there is looking to do the same…
A Little Development Environment Background…
My current client is a typical large enterprise with almost all-things Microsoft. Recently, things have changed a bit with our R&D team because we’ve introduced Ruby / Rails development on Mac Book Pro laptops running OSX Snow Leopard. As is the case with many slow-to-adopt IT departments, our Mac Book development machines are either not required or are not allowed to participate in the corporate domain. It seems to me to be either a fear of the unknown or an unwillingness to support something outside of the status quo – I think that answer will change depending on who ask. Reasons aside, local development must mimic the production environment as close as possible to catch any configuration surprises early in the development process.
Step 1: Server Internet Connectivity
Internet connectivity is the easy part… Unless you use some weird, custom setup during your VM build-out, VirtualBox will add a default NAT network adapter to ensure the VM has an active Internet connection. No need for further configuration here.
Virtual Machine Settings: NAT Network Adapter
Step 2: Pseudo-Static IP Setup to Replace NetBIOS
As I mentioned earlier in this post, our development machines are not part of the corporate domain. The same is true with our development VMs even though they are Windows servers. Joining a server or development machine to the corporate domain is the only way I know of to be able to assign it a static IP address. It’s also the only way I know of to use NetBIOS to connect to the machine using it’s assigned machine name rather than using a static IP address.
Absence of a corporate domain is obviously a problem here… To work around it, we need some VirtualBox customization. I found a solution in adding a second VM network adapter: a Host-Only Network Adapter. It is possible to setup your own local domain using the Windows Server 2008 R2 DNS Server Role. But for a single-server environment, I didn’t want the hassle of setting up and maintaining my own local domain. So I set up the Host-Only adapter to use DHCP. You’ll see from the screenshots below that my DHCP settings provide for a relatively wide range of IP address settings, but the nice thing about VirtualBox’s DHCP server is that it will always assign the first sequentially available IP address to every VM you bring online. In other words, my single VM instance always gets the IP address listed in my DHCP server’s “Lower Address Bound” setting. Bingo! I always get the following IP address for my SQL Server VM: 18.104.22.168.
To change VirtualBox’s DHCP server settings, go to “Preferences” in the application settings. From the “Network” tab, use the edit button (screwdriver icon) to modify the network settings for the host-only network.
VirtualBox Host-Only Network Listing
The DHCP Server will probably not be enabled by default, so be sure to configure it accordingly.
VirtualBox Host-Only Network Adapter and DHCP Server Settings
Now you’re done with the VirtualBox server settings. The last part of the configuration is to add a second host-only network adapter to the SQL Server VM. After adding the second network adapter, be sure to assign it to the same virtual network that was configured for DHCP access. If you’ve only configured a single VirtualBox host-only network, you don’t need to worry about assignment as it will default correctly.
Virtual Machine Settings: Host-Only Network Adapter
And that’s it. You’re now ready for server and database connectivity via IP address resolution. Below is a screenshot of the VM’s IP configuration. Notice the dual network adapters.
Virtual Machine IP Configuration