One of the things I did frequently when using VMware is connect from my host (usually Windows) to my guest (usually Linux). The fact that I don’t really remember how I set that up seems to indicate that it was pretty trivial or just worked “out of the box” (which is a funny thing to say about a VM). After happily using Virtualbox for a while now, the need to connect from host to guest has inevitably reared its head and I was a little surprised that there does not seem to be a straight forward way to do that. Turning as one usually does in such a situation, to Google, and since it was a bit of a fiddle I thought I would scrawl it down here.
The Windows version:
Open the Windows command line and navigate to
There are three commands that need to be issued. The command is a little daunting at first glance so here are the important parts:
“karmic” is the name I gave my VM when I created it.
“pcnet” refers to the PCNet virtual network card that I am using in my VM which you can select in your network settings. e1000 is also valid if thats what you’re using.
“railsdev” is the name that will be given to the port forwarding configuration that these commands set up.
The rest should be fairly self explanatory:
C:\Program Files\Sun\VirtualBox>VBoxManage.exe setextradata “karmic” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/railsdev/Protocol” TCP
C:\Program Files\Sun\VirtualBox>VBoxManage.exe setextradata “karmic” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/railsdev/GuestPort” 3000
C:\Program Files\Sun\VirtualBox>VBoxManage.exe setextradata “karmic” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/railsdev/HostPort” 3000
On *nix things are roughly the same, except that the default network card is the Intel Pro/1000 instead of the pcnet you can see above. Consequently you will need to do something like this:
vboxmanage setextradata “mavrick_server” “VBoxInternal/Devices/e1000/0/LUN#0/Config/rails/Protocol” TCP
vboxmanage setextradata “mavrick_server” “VBoxInternal/Devices/e1000/0/LUN#0/Config/rails/GuestPort” 80
vboxmanage setextradata “mavrick_server” “VBoxInternal/Devices/e1000/0/LUN#0/Config/rails/HostPort” 8080
You can see that here I am forwarding port 8080 on the host to port 80 on the guest and naming the forwarding configuration “rails”. Also notice the “e1000” that identifies the network card. Other things to note are that the quotes around the VM name (“mavrick_server” in the above example) MUST be there and they must be regular quotes not angled ones like “ or ”. Angled quotes will be assumed to be part of the machine name and throw an error like this:
ERROR: Could not find a registered machine named ‘“webserver”’
Replace the quotes with proper ones and you should be good.