Daniel J. Pritchett’s Posterous mailblog

Daniel J. Pritchett’s Posterous mailblog

Daniel Pritchett  //  Enterprise collaboration blogger, Fortune 100 Business Intelligence developer, father, husband. These are my stories.

Main blog: Sharing at Work

Oct 19 / 10:43am

VirtualBox NAT port forwarding setup

If you have decided to run VirtualBox in NAT mode then you won't be able to access the virtual machine over the network without a little extra configuration.  The commands below  will allow you to forward ports from your VM to your host machine so that you can connect via SSH and HTTP.
I chose guest port 22 for obvious reasons - you'll need an SSH connection to work on your box.  Port 3000 seems to be the default for Ruby's WEBrick server - the one you'll be testing and developing with.  You can transfer files across port 22 (2222 after you forward it) using Filezilla or any other client that supports secure file transfer over SSH.  I think SSH + HTTP is all you'll need here, but if not you can always map more ports.
Note that each of the commands below should be one line, even if it's wrapped by Posterous.  Feel free to save the bolded text as a .cmd script and execute it all at once.
c:
cd "\Program Files\Sun\VirtualBox"
VBoxManage setextradata "Rails" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
VBoxManage setextradata "Rails"      "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22
VBoxManage setextradata "Rails"      "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 2222

VBoxManage setextradata "Rails"      "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/Protocol" TCP
VBoxManage setextradata "Rails"      "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/GuestPort" 3000
VBoxManage setextradata "Rails"      "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/HostPort" 3333

--
Daniel J. Pritchett
http://www.sharingatwork.com
Loading mentions Retweet

1 comment

Oct 26, 2009
Looks like the Rails web server is Mongrel, not WEBRick. Whoops.

Leave a comment...

 
Got an account with one of these? Login here, or just enter your comment below.
Posterous-login    Connect    twitter