How to easily map ports on VirtualBox

To setup easily a map between your host and your guest, you need to do these commands in root :

VBoxManage setextradata {guest name} "VBoxInternal/Devices/pcnet/0/LUN#0/Config/{mapping name}/HostPort" {host port}
VBoxManage setextradata {guest name} "VBoxInternal/Devices/pcnet/0/LUN#0/Config/{mapping name}/GuestPort" {guest port}
VBoxManage setextradata {guest name} "VBoxInternal/Devices/pcnet/0/LUN#0/Config/{mapping name}/UDP" 0
  • {guest name} : Name of the guest
  • {mapping name} : String to identify the nature of the mapping (http, ftp, ssh etc)
  • {host port} : Host port
  • {guest port} : Guest port

To remove a map, just do theses same commands, but without {port guest} :)

(Find at : http://nicoleau.fabien.free.fr/weblog/index.php?post/2007/11/11/Config-NAT-pour-acceder-a-votre-machine-virtuelle-VirtualBox (in french))

Posted by Cyril Nicodème