ubuntu host windows10 guest trouble with port forwarding

Discussions related to using VirtualBox on Linux hosts.
Post Reply
shen
Posts: 1
Joined: 9. Nov 2021, 15:37

ubuntu host windows10 guest trouble with port forwarding

Post by shen »

Hello, I appreciate the help in advanced. I have a custom webserver written in Flask running on my Ubuntu 20 host, a custom client to the webserver is running on my Windows 10 guest in virtualbox. I have spent over a week to try to figure out how to correctly configure the port forwarding to allow the client in Windows 10 to communicate with the webserver on the Ubuntu host but I am totally stuck. Any help and/or suggestions would be appreciated. Appended below are the relevant commands and output that may be helpful for problem solving. The forum wont let me post ip addresses so I have just renamed them host and guestipaddress. I am also not able to post this message if I say i-p,t-cp or h-ttp so the question looks kind of funky.

Ubuntu host
$./start_server.sh –production
./start_server.sh: line 12: [: ==: unary operator expected
I-P > 138.5.54.69
Serving on h-ttp://0.0.0.0:8080

to check that the server is active:
$ lsof -i :8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
waitress- 143701 user 8u I-Pv4 3430485 0t0 T-CP *:h-ttp-alt (LISTEN)

Virtual Box
NAT port forwarding T-CP host : 138.5.54.69 port 8080 guest: 10.0.2.15 port 8080
Notes:
I’ve tried leaving IP address blank it still does not work.
Notably, if I run virtual box before starting the server on Ubuntu the server will not start because the port is already in use by Virtualbox.

Windows 10 guest
removed Mcaffe

advanced settings firewall:
inbound rules port 8080 allow connection any connection all profiles, all interfaces, allow edge transversal
outbound rules port 8080 allow connections any connections all profiles

C:\netstat -ano | findstr 8080 shows no traffic
C:\telnet 10.0.2.15 8080 not able to connection

webserver client on windows 10 cannot find server

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

Re: ubuntu host windows10 guest trouble with port forwarding

Post by scottgus1 »

shen wrote:webserver ... running on my Ubuntu 20 host...
client to the webserver is running on my Windows 10 guest...
Virtual Box NAT
Please see Virtualbox Networks: In Pictures: NAT. Also note that "NAT" and "NAT Network" are close cousins but are slightly different, and NAT Network can be broken if the wrong things are done with it. Please clarify if you are really using NAT Network instead of straight NAT.

Your setup is client in the guest, server on the host. This means that the client is trying to access the host through NAT. This is typical NAT router-style network access and does not require a port forward. Port forwarding would be required if your setup was the other way around: if the server was in the guest and the client was on the host.

NAT and its cousin NAT Network act like typical house routers. A house router allows your computer on the private side to get access to anything on the public side. Same with Virtualbox NAT. NAT's private side is in the VM, the public side is on the host. The guest is allowed to access anything on the host side. No port forwarding is needed.

What is needed, though, is to open a port in the host's firewall. Your client guest is trying to access the server host, and the server host needs to be open to that access on the desired port. The host firewall is an Ubuntu setting, not handled through Virtualbox.
Post Reply