Headless VirtualBox with Windows 7 guest

Virtualbox logoContinuing my VirtualBox series, let’s talk about headless VirtualBox.

You can run any VBox machine on headless mode, without the GUI. This is particularly interesting for *nix servers where you don’t want to install the X components, but it’s also interesting for Windows boxes that you can use as servers, in order to save some resources (memory, cpu,…) while it’s running.

Use case

I have a Windows 7 box running VPN software (that only runs in Windows), but I don’t want to use the Windows GUI and keep switching from the Mac to the Windows UI do do some things.

Solution

Configuring VirtualBox

Set an IP for your Windows guest, for easier configuration. You could use port forwarding too, but that’d be more cumbersome.

Install VirtualBox extension pack to enable remote display (VRDP support). In the host install a RDP viewer, for instance, for OS X, Microsoft Remote Desktop client.

Configure the guest vbox, enabling in settings Display -> Remote Display and set authentication method to null for no authentication. There are other options for authentication, if you want to check.

Manage the VM headless with VBoxHeadless and VBoxManage commands


# start the VM

VBoxHeadless -s "Windows 7"

# save VM state

VBoxManage controlvm "Windows 7" savestate

Connect to the running VM with your RDP client as you would do with any Windows box.

Web browsing from the host

Install a proxy server on Windows, FreeProxy for instance, but there should be better options out there.

Use FoxyProxy on Firefox on the host, configuring all the remote VPN urls to go through the Windows server. Then you can connect from your host’s Firefox to any url in the VPN.

SSH and other ports from the host

On the Windows guest, connect with Putty to a SSH server on the VPN side, and configure port forwarding. Then you can connect to your VM ip on the ports you forward and end up in the remote server. You could set a server name on /etc/hosts with the VM ip so it’s easier to remember.

With this setup I can use my Mac Firefox, iTerm and other tools without needing to use the Windows interface.