VirtualBox: Bridged, NAT or Neither?

Google the phrase ‘VirtualBox set up’ or similar and you’ll find plenty of guides that will instruct you on the install of a Virtual Machine (VM) with the network adapter set to either NAT or Bridged. While these options work fine, as a web developer you are quick to realise their limitations. So what does a web developer need from their VM networking set up? Simple:

  1. To simply and consistently connect to the guest VM from the host, and
  2. To connect to the Internet, remote servers and web applications from the guest VM with the same ease as the host.

Once a VM has been installed, the first goal can be expanded into some real world use cases:

  1. To immediately be able to SSH into the guest machine from a terminal to configure the environment.
  2. To connect to another port on the guest VM via an SSH tunnel, i.e. to administer MySQL from a GUI client.
  3. To request web sites running in the VM through the host’s web browser on the HTTP and HTTPS ports.
  4. To be able to connect to any other port which maybe required. For example, my VMs run Zend Server so I need to connect over HTTPS on port 10082.
  5. To be able to connect to the guest VM regardless of my location or the network I’m connected to.
  6. To set this up once and not have to worry about a guest VM having different IP addresses every now and again.

As for the second goal, the following use cases should be met:

  1. To immediately be able to connect to the Internet and perform system updates and software installs from the guest VM.
  2. To be able to piggy back on a host’s private VPN connection.
  3. To have exactly the same ACL rules as the host when connecting to remote servers or services.

So which network adapter satisfies all of the above use cases? NAT or bridged?

Continue reading