Using VirtualBox as your personal server

VirtualBox is an open source virtualization program (for those of you that don’t know what that means: simply put it is a computer program that can emulate other computers within your own computer). One of the things that I use it for is to run my personal development and testing servers within my own workstation that don’t exist to the outside world. You don’t have the mess of dual boot, nor do you have the need for lots of additional hardware for your development and testing setups!

To be able to develop and test on such a VM I generally require it to be available as if it is on the network (per example via SSH, or my browser). Assuming that you have installed VirtualBox and that you know how to setup a VM already, I’ll briefly explain the specifics of setting up a VM that you can access as if it were on the network:

  • When creating the VM give it two network adapters.
    • Adapter 1 setup as “NAT”, this gives the VM access to whatever network your computer is connected. This includes the internet if you’re connected to it, which can be useful to download OS updates or applications inside your VM (I often have VMs running Ubuntu, and the NAT adapter allows me to use apt painlessly).
    • Adapter 2 setup as “VirtualBox Host-Only Ethernet Adapter”. This gives the VM an IP address within a private range, that only exists within your own computer.

When installing an OS on your VM, it is useful to give the it a static IP address for adapter 2. Having a static IP for each VM will allow you to connect to it using bookmarks instead of having to check what the IP of each VM is after it has started. Note that you do have to adhere to the IP range defined in the VirtualBox preferences for the host only adapter. You can find this information via the menu: go to “File” -> “Preferences”, go to the “Network” section and double-click on the host only adapter entry to get a popup where you can see/configure the network range and the DHCP server settings (you probably want to ensure that your static IPs cannot be given out by the host only adapter’s DHCP server).

Tags: , , , ,

  1. Tino Kremer’s avatar

    VirtualBox works great. I have been using it myself for quite some time, but since I’m running Windows 7 I have switched to Microsoft Virtual PC. It’s nicely integrated in windows, but more important, it runs much smoother. Microsoft needed it’s VM to work well as the “Windows XP mode” is also running on the platform. For those who don’t know, “Windows XP Mode” is what Microsoft offers on e.g. Windows 7 Ultimate to be able to run “old” apps that don’t run on Windows 7 directly. As the VM hosts a full Windows XP installation, everything that worked on Windows XP will work here as well.

    Anyway, since I’m using this one the memory requirements has dropped considerably and speed has increased.

    Note I’m running Windows as Host and Guest which could be the reason it runs smoother compared to VirtualBox. In Linux there is no Microsoft Virtual PC anyway :D