Same Port Forwarding on two VMs.

Discussions related to using VirtualBox on Linux hosts.

Same Port Forwarding on two VMs.

Postby hack3rcon » 13. Apr 2021, 15:35

Hello,
I have two VMs and I configured Port Forwarding on both of them as below:
Code: Select all   Expand viewCollapse view
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.
hack3rcon
 
Posts: 142
Joined: 28. Feb 2016, 10:44

Re: Same Port Forwarding on two VMs.

Postby scottgus1 » 14. Apr 2021, 00:03

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.
scottgus1
Site Moderator
 
Posts: 11702
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.

Postby hack3rcon » 19. Apr 2021, 11:57

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?
hack3rcon
 
Posts: 142
Joined: 28. Feb 2016, 10:44

Re: Same Port Forwarding on two VMs.

Postby fth0 » 19. Apr 2021, 13:02

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.
fth0
Volunteer
 
Posts: 1873
Joined: 14. Feb 2019, 03:06
Location: Germany
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...

Re: Same Port Forwarding on two VMs.

Postby hack3rcon » 26. Apr 2021, 10:34

Thank you.
hack3rcon
 
Posts: 142
Joined: 28. Feb 2016, 10:44


Return to VirtualBox on Linux Hosts

Who is online

Users browsing this forum: No registered users and 13 guests