VirtualBox on the Mac

On my Desktop with Ubuntu as the Host operating system, I use simple NAT as the networking solution. As the documentation suggests, thats the simplest way to do what I need, which is simple browsing on the Windows VM.
For any new hostnames I add to the development server, I have to add a corresponding entry on the Windows hosts file, but that's trivial.
The Desktop never moves, so its had the same dynamically assigned IP address since day 1.

Its slightly different on my laptop.

We are now dealing with a different scenario. The development is also done on a VM [Ubuntu]. Instead of VM to Host machine communication, we have to deal with VM to VM communication, and indeed Host to VM communication.
NAT could still do the job, but it is awkward enough to get port forwarding working from Host [Mac] to VM [Ubuntu]. Getting from VM to VM via the Host... tricky.

Greggles deals with this by using a 'bridged' network adapter. This is trivial to set up, and the VMs and Host all get a dynamically assigned IP from the DHCP server. As Greggles mentioned, this requires editing the hosts file on any machine if things change.
My laptop moves from network to network, wired and wireless, so the host IP address changes quiet a bit.

It's not ideal, if you're moving about as much as I am.
And there is one big gotcha.
Bridged networking relies on the presence of a DHCP server, so if you're offline, so are your VMs. I found this out to my cost my on a long train journey, so hence this blog post!

So what other options are there.
VirtualBox offers 'Internal Networking' which looked like it would do the job, but 'internal' means just that. Communication is between VMs only. No Host to VM traffic allowed. So I can't test any websites deployed on the Ubuntu VM from my Mac, nor can anybody else connect onto the laptop to test.

Lastly, Host-Only networking might provide a solution. For my purposes, this is essentially the same as Internal networking, but the host machine gets to play along too.
In both Internal and Host-Only networking, Virtualbox can act as a DHCP server, which makes networking configuration a little easier.

Host-Only has some neat advantages. I can retain the same IP address for all attached machines if I wish [in particular the Ubuntu VM], this negating the need to changes the Hosts files too often.
My Mac can now test the websites too, even when I'm working off-line.
Lastly, there is still a way to let other people on other machines test websites running on the VM. In the configuration for a VM, you can enable multiple Network adapters. For the Ubuntu VM, I enable a second network adapter, in Bridged mode.

I did have difficulty getting the Virtualbox software save my 'Host-only' settings. On the Mac, there's a quirky little bug whereby whereby Host-Only  settings seem to disappear. Ironically this happens when you don't have an active network connection.

I'm stll having trouble with my Windows VMs as the new downloads from Microsoft seem to require activation. I don't remember the earlier VMs provided requiring activation. No luck yet on a solution to that point.
 

Powered by Drupal, an open source content management system