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).