For a long time VMWare Workstation has been my weapon of choice for virtualisation. I’ve used it for everything from a VM to test apps in to setting up a small domain. I’ve always just done the same things to setup a VM: create a machine, install the guest OS and install VMWare tools. VMWare even has a wizard to automate the last two steps.
Much to its credit (or my detriment, depending on your point of view) I’ve never had to dive deeply into any hows or whys, it’s just worked. Until now.
A couple of days ago I started messing with TeamCity and decided to set it up in a VM. I followed my normal three steps to configure a VM, installed TeamCity and started, happily, CI’ing away. I suspended the VM and closed VMWare, this proved to be a fatal mistake.
When I resumed the VM, it could no longer connect to the network. I hadn’t changed any settings and before suspending the VM I could connect to the TeamCity web interface from both my laptop and desktop. So I started with some basic ‘power cycling’. I restarted the VM then VMWare with the VM shutdown and, finally, the host. It didn’t make any difference, so I went on to checking the VM’s OS settings but nothing jumped out as being wrong.
I had deliberately set up the VM to use bridged networking so it could be accessed outside of the host. Switching the networking type to NAT restored network connectivity to the VM but now it couldn’t be accessed. But it confirmed the problem was with the host not the VM.
Knowing roughly where the problem was I checked what network adapters my machine had installed. It had four:
The two VMware connections are for host only and NAT networking, ‘Local Connection’ is my physical adapter and VirtualBox is for exactly what it claims. VirtualBox, that jogged my memory, the last time that I had used VMWare was before installing VirutalBox to experiment with (Ultimately, I didn’t like it because of the host/guest folder sharing). At this point I was wondering if VMWare were deliberating punishing me for trying VirtualBox but that seemed a tad implausible.
I then started to wonder how VMWare knew what adapter to bridge with and noticed VMWare Virtual Network Editor. I fired it up and spotted the problem almost immediately:
The bridge was automatically selecting the network connection and changing the ‘Bridged to:’ option to my network card restored the VM’s network connectivity. I have no idea why it selected the VirtualBox adapter over the physical one randomly, maybe it just fancied meeting someone new. But this got me back to my blissful CI’ing.
Having read about this a bit further it seems to be a common problem for it to select wireless network cards and not reselect the wired one when you change. So this is a good first port of call if you lose network in a VM.