Page 1 of 1
Configuring NAT port forwarding
Posted: 3. Nov 2008, 11:45
by orro
I'm a new bee of VB, and have searched the forum but too many results coming back that makes me can not identify my questions.
I have meet some problems when I use 2 network cards for the GUEST OS, and use NAT and set port forwarding for special services.
My first question is: How can I identify 2nd network card from blow line,
Devices/pcnet/0/LUN#0/Config - pcnet/1/LUN#0 or pcnet/0/LUN#1 ?
What about 3rd and 4th network card?
2nd question is: How can I add 1 more protocol for specific service?
for example, I have indicate TCP to MySQL on 3306 port, now I want to add UDP to this port also, how can I do it?
Any advise will be greate appreciate.
Re: The questions of the Virtual Box
Posted: 3. Nov 2008, 20:25
by TerryE
Hi orro and welcome to our forum. You might want to take this opportunity to browse the
Forum Posting Guide. This contains some useful tips on how to search for VBox knowledge and how to frame Qs. (BTW, you will see that I've change you title to reflect your Q.)
orro wrote:Devices/pcnet/0/LUN#0/Config - pcnet/1/LUN#0 or pcnet/0/LUN#1 ?
The trick here is to look at the Devices enumeration listed in the VBox.log (focus on the VM in the VBox GUI and hit ^L to browse this). Each different device driver type has a name. In this case
pcnet for PC Network. You can have multiple devices, and each has a config. The config tells you what the specific type is, etc. Some device drivers (such as IDE) can have multiple LUNs. Now the point is that the different NICs can be different virtual devices, so they must be
Devices/pcnet/0 up to
Devices/pcnet/3 for network cards 1 to 4.
orro wrote:How can I add 1 more protocol for specific service?
for example, I have indicate TCP to MySQL on 3306 port, now I want to add UDP to this port also, how can I do it?
Easy, just add another block of 3 setextradata commands to specify the map are just use the following batch script
Code: Select all
@echo off
rem
rem SetVMportMap.cmd
rem
rem P1 = VM name or UUID
rem P2 = Device Number
rem P3 = Service Name. This is arbitrary but should be unique for each triplet
rem P4 = Protocol
rem P5 = guest port
rem P6 = host port
rem
rem EXAMPLE
rem
rem call SetVMportMap.cmd myVM 0 mysqlUDP UDP 3306 3306
rem
set SVM=VBoxManage setextradata %1
%SVM% VBoxInternal/Devices/pcnet/%2/LUN#0/Config/%3/Protocol %4
%SVM% VBoxInternal/Devices/pcnet/%2/LUN#0/Config/%3/GuestPort %5
%SVM% VBoxInternal/Devices/pcnet/%2/LUN#0/Config/%3/HostPort %6
:end
Posted: 4. Nov 2008, 01:33
by orro
Thanks Terry!
That's solved my problem running Virtual Box!
And thank you for changing my subject!
Posted: 18. Nov 2008, 15:21
by ceone
thx a lot i was struggling on that commands since this morning your script saves me

that does not work on multiple guests
Posted: 24. Feb 2009, 16:33
by advance38
As stated above, you can configure multiple settings for different types of port forwarding. e.g. guestssh and guesthttp. But notice that those settings are usually only possible for one guest OS at the same time, unless you use host interface.
That's because a guest OS under NAT must have its IP address 10.0.2.15, the default IP address, in order to let port forwarding work correctly. If a guest OS has any other IP address, say 10.0.2.19, then port forwarding does not work at all. Therefore you cannot enable multiple port forwarding for multiple guests at the same time, since only one guest is able to have the IP address 10.0.2.15.
I don't know why VirtualBox doesn't support such a functionality. It looks somehow weird, though it's true as I have tried so far.
Posted: 24. Feb 2009, 18:01
by TerryE
Your wrong. I've used multiple VMs at the same time port fowarding the same service. You just need different port numbers. E.g. I had 3 VMs with ports 2221, 2222, 2223 forwarding to their respective port 22 for SSH control.