Opening and Forwarding Ports To A VirtualBox-based Guest

Here are the commands used to open and forward the host’s port 2222 to the guest’s port 22 (SSH Server Port).

Type this into a terminal:


VBoxManage setextradata nameofyourguest "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" 2222
VBoxManage setextradata nameofyourguest "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" 22
VBoxManage setextradata nameofyourguest "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" TCP

Could also be used to forward PostgreSQL and HTTP:


VBoxManage setextradata nameofyourguest "VBoxInternal/Devices/pcnet/0/LUN#0/Config/postgresql/HostPort" 5432
VBoxManage setextradata nameofyourguest "VBoxInternal/Devices/pcnet/0/LUN#0/Config/postgresql/GuestPort" 5432
VBoxManage setextradata nameofyourguest "VBoxInternal/Devices/pcnet/0/LUN#0/Config/postgresql/Protocol" TCP
VBoxManage setextradata nameofyourguest "VBoxInternal/Devices/pcnet/0/LUN#0/Config/http/HostPort" 8080
VBoxManage setextradata nameofyourguest "VBoxInternal/Devices/pcnet/0/LUN#0/Config/http/GuestPort" 80
VBoxManage setextradata nameofyourguest "VBoxInternal/Devices/pcnet/0/LUN#0/Config/http/Protocol" TCP

Related posts:

  1. Howto Access via ssh a Virtualbox Guest machine
  2. Sockets Programming in Java
  3. Convert from VMWare To VirtualBox
  4. How to mount bin / cue image files in Linux
  5. MySQL Optimization and Performance Tips
  6. Gaming with Intel GMA 900, GMA 950, 915 or 945 GL/GV/GM Based Chipsets

Popular Related Items »

2 Comments »

  1. Christ said,

    September 25, 2008 @ 11:40

    Thanks. Unfortunately, the guest is still closing the connection when using pgAdmin to connect. Did you get this to work?

  2. Redirecionando portas para VirtualBox. @ Matheus Bratfisch said,

    May 18, 2009 @ 19:49

    [...] IPtables Tutorial IPTables Port Redirect VirtualBox, com nat VBoxManage Port Forward Linux porta, redirecionamento, [...]

RSS feed for comments on this post · TrackBack URI

Leave a Comment