Page 1 of 1

Multiple Ports Forwarding

Posted: 12. Oct 2007, 20:28
by oanaradu32
Hi,

does anyone know how to forward more than one port?

The network connection between Host and Guest works fine, Port Forwarding for only one port also works fine.

For example:

For port 22(ssh) i have this:

"c:\Program Files\innotek VirtualBox\VBoxManage" setextradata "fedora7" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP

"c:\Program Files\innotek VirtualBox\VBoxManage" setextradata "fedora7" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22

"c:\Program Files\innotek VirtualBox\VBoxManage" setextradata "fedora7" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 22

But if i want tot forward another port (80 HTTP) only the last port that i forwarded will be working.

Thanks.

Posted: 15. Oct 2007, 14:57
by oanaradu32
I suppose it is not yet possible, only with a host interface.

Ok then I will wait for the next version.

Thanks.

Same with me...

Posted: 18. Oct 2007, 19:20
by jonatasln
I'm dealing with the same issue, I need to port forward more than one port to an Ubuntu 7.04 running on a Windows XP SP2 host and, due to company firewall restrictions, it's very desirable access this Linux resources via NAT.

Anybody knows a way to port forward 2 or more ports without bridging the virtual Linux host interface? Or, if this configuration is officially unavailable?

Thanks,

Posted: 3. Nov 2008, 18:58
by podollb
Yeah it seems you can only forward port one port from your host to your guest (as of VirtualBox 2.0.4). It would be great if VirtualBox fixed this.

But, in the meantime you can get around this limitation by port forwarding 22 and then tunneling all the other ports thru that. You can read more by doing a web search for "tunnel ports thru ssh".

Posted: 3. Nov 2008, 19:30
by podollb
I was wrong. You just have to use a different name in that path, instead of "guestssh" you could have "guesthttp", etc. Here's an example:

To forward port SSH:

Code: Select all

VBoxManage setextradata "Linux Guest" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
VBoxManage setextradata "Linux Guest" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22
VBoxManage setextradata "Linux Guest" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 2222
To forward port HTTP:

Code: Select all

VBoxManage setextradata "Linux Guest" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/Protocol" TCP
VBoxManage setextradata "Linux Guest" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/GuestPort" 80
VBoxManage setextradata "Linux Guest" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/HostPort" 8080

Posted: 3. Nov 2008, 19:30
by Dest
you could always setup more than one NIC for now

Posted: 3. Nov 2008, 19:38
by podollb
I think my last post works great, even with one nic.

Posted: 3. Nov 2008, 20:40
by TerryE
Guys, have a look at my answer on http://forums.virtualbox.org/viewtopic.php?t=11053

You can have as many redirects as you want as long as the descriptor (eg "guestssh" is your example) is unique for each (Protocol, GuestPort, HostPort) triple.

Posted: 12. Nov 2008, 18:45
by podollb
Is there a way to port forward ranges of ports? I have a J2EE app that needs RMI ports open 12401 - 12500 and it'd be nice if I could just do that in a range rather than one by one...

Posted: 12. Nov 2008, 18:50
by podollb
For now I'm just doing it in a loop...

Code: Select all

#!/bin/bash
for a in {12401..12500}
do
  VBoxManage setextradata "myServer" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/rmi_$a/Protocol" TCP
  VBoxManage setextradata "myServer" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/rmi_$a/GuestPort" $a
  VBoxManage setextradata "myServer" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/rmi_$a/HostPort" $a
done 

Posted: 13. Nov 2008, 04:07
by TerryE
That would work :-)