Multiple Ports Forwarding

Discussions related to using VirtualBox on Windows hosts.
Post Reply
oanaradu32
Posts: 2
Joined: 12. Oct 2007, 20:15

Multiple Ports Forwarding

Post 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.
Homepage: www.queeq.com
oanaradu32
Posts: 2
Joined: 12. Oct 2007, 20:15

Post by oanaradu32 »

I suppose it is not yet possible, only with a host interface.

Ok then I will wait for the next version.

Thanks.
Homepage: www.queeq.com
jonatasln
Posts: 1
Joined: 18. Oct 2007, 18:45

Same with me...

Post 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,
Regards,

Jon
podollb
Posts: 27
Joined: 9. Nov 2007, 08:21

Post 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".
podollb
Posts: 27
Joined: 9. Nov 2007, 08:21

Post 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
Dest
Volunteer
Posts: 138
Joined: 11. Jan 2008, 17:03
Primary OS: MS Windows Vista
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 2000, Windows XP, Ubuntu, FreeBSD

Post by Dest »

you could always setup more than one NIC for now
podollb
Posts: 27
Joined: 9. Nov 2007, 08:21

Post by podollb »

I think my last post works great, even with one nic.
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Post 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.
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
podollb
Posts: 27
Joined: 9. Nov 2007, 08:21

Post 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...
podollb
Posts: 27
Joined: 9. Nov 2007, 08:21

Post 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 
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Post by TerryE »

That would work :-)
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
Post Reply