Same Port Forwarding on two VMs.

Discussions related to using VirtualBox on Linux hosts.
Post Reply
hack3rcon
Posts: 204
Joined: 28. Feb 2016, 10:44

Same Port Forwarding on two VMs.

Post by hack3rcon »

Hello,
I have two VMs and I configured Port Forwarding on both of them as below:

Code: Select all

Host IP        Host Port        Guest IP        Guest Port
127.0.0.1      2080             10.0.3.15       80
Both of my VMs running Apache Web Server. If I browse "http://127.0.0.1:2080" on my host OS, then it forwarded to which VM?

Thank you.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Same Port Forwarding on two VMs.

Post by scottgus1 »

Probably either the first VM that started, or a crap shoot between the two depending on which VM's network code is in the processor when the request comes in. I don't think there is a way for us to tell without experimentation.
hack3rcon
Posts: 204
Joined: 28. Feb 2016, 10:44

Re: Same Port Forwarding on two VMs.

Post by hack3rcon »

scottgus1 wrote:Probably either the first VM that started, or a crap shoot between the two depending on which VM's network code is in the processor when the request comes in. I don't think there is a way for us to tell without experimentation.
Is it not a problem?
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Same Port Forwarding on two VMs.

Post by fth0 »

scottgus1 wrote:Probably either the first VM that started
This. Starting a VM means creating and running a VirtualBoxVM process in the host OS, which will then try to bind to the networking port exclusively. The networking stack of the host OS will typically accept the first process and reject others. Otherwise, another process (or application) could steal the port from the first process. In consequence, the first VM started will win.
hack3rcon
Posts: 204
Joined: 28. Feb 2016, 10:44

Re: Same Port Forwarding on two VMs.

Post by hack3rcon »

Thank you.
Post Reply