Virtual Box 3.1, Ubuntu and Mac - Networking Tricks

06 Dec 2009

Yup, it's that time again, more Virtual Box and Mac tricks. First Virtual Box 3.1 came out recently. It contains something called "Host Only Network" which is very handy

If you are running a guest desktop OS and do not need to network connect to a server running on the guest OS, then the NAT networking option is all you need. Ignore the rest of the article. NAT "shares" an interface with the host, it's great to allow the guest make outbound connections. But you can't SSH in.

To do that, you need to use "Bridged Adapter." It behaves like a "different computer" on the network. The guest gets it's own IP address from the whatever DHCP server is out there. But: No wifi, no IP. Which means you can't log into the server. Ooops. And if there is wifi, the IP address might (will) be different every time. It also means your guest can be attacked by the outside world.

With Virtual Box 3.1, comes with a new type of networking called "Host Only". It is a bit weird. The guest can't connect to the internet, and "only your computer" (the host) can connect to it (the guest). The IP address it gets is "stable" (the same every time it boots)

So if you set up two networking adapters (virtual box supports 4), one being the "NAT", and the other being "Host Only", you get the best of both worlds. Outbound connectivity when it exists, and inbound activity only from your host (which likely means YOU at the keyboard). Ta-da!

Adding a new network and existing Ubuntu Server

Great you updated your VBox settings and have a snazzy new interface. How can you get Ubuntu recognize it? Hack the /etc/network/interfaces file. You probably just want to add to the end:

auto eth1
iface eth1 inet dhcp

New installs should recognize the adapters automatically.