VirtualBox port forwarding, running headless and disabling GDM on 10.04

Phew that was a long heading. Things have changed in VirtualBox 3.2.4, setting up port forwarding is lot easier now and more readable. Adding notes for setting up and configuring my linux dev vm.

Install or import a new appliance and disable gdm, if all you need to do is run a couple of services on it, no point wasting memory running gdm.
Edit grub configuration

sudo vi /etc/default/grub

and edit the following lines.

#GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX_DEFAULT="text"

comment out the first line and add the second one and then update the conf

sudo update-grub2

Now setup/install ssh atleast before you configure anything else.

sudo apt-get install openssh-server

Now reboot the vm to test if it all boots fine and doesn’t start the X server. Now turn it off again and this time boot it again as headless so its just a process like any other program running on your computer and possibly more efficient in terms of memory requirement.

But before that configure port forwarding. The syntax is for network connection setup as NAT

VBoxManage     modifyvm     [--natpf<1-N> [<rulename>],tcp|udp,[<hostip>],
                                          <hostport>,[<guestip>],<guestport>]
                                              [--natpf<1-N> delete <rulename>]

So based on this, to setup port forwarding from localhost port 2222 to guest port 22, the following and start the vm headless.

mac-host:~rpandit1016$ VBoxManage modifyvm "ubuntu-x11" --natpf1 "guestssh, tcp,, 2222,, 22"
mac-host:~ rpandit1016$ VBoxHeadless --startvm "ubuntu-x11"
Oracle VM VirtualBox Headless Interface 3.2.4
(C) 2008-2010 Oracle Corporation
All rights reserved.

Listening on port 3389.

Now you can configure more services by logging in. Remember to ensure that your VM is switched off though when you want to add a new rule, otherwise it will fail everytime you try and add it.

About rp

Architect for large, highly scalable LAMP applications and Technical Manager with special focus on metrics based continuous improvement of teams and products. Rajat has close to a decade of experience of a very wide range of skills related to infrastructure, middleware, app servers all the way to front-end technologies and software development methodologies including agile, iterative waterfall, waterfall as well as ah-hoc startup using the right approach in the right context to reduce time to market.