Hi,
If we access from outside, the packet path is:
(outside packet) --> gateway firewall (port forwarding) --> ubuntu server firewall (exception is added) --> the desired program
For this issue, we can try the 3-step troubleshooting:
1, in one of the ubuntu servers, use netstat -ntlp to show all the listening ports and program, and we need make sure the desired program is in it.
use following command to open these ports in the firewall. If you have already done this through network manager, skip this.
note: the command may differ among different distros of linux
firewall-cmd --zone=public --add-port=<port>/tcp --permanent
firewall-cmd reload
2, in the other ubuntu server (assuming they are in the same subnet), run the following command to test the port. If pass, continue with next step, otherwise, check the ubuntu server firewall settings.
nc -vz <ip address of the first ubuntu server> <port>
3, if we want to access from outside of the subnet, we need to configure the port forwarding in the gateway to allow the traffic.
note: the gateway could be windows/linux comptuer, router or something similar, either on-premises or in the cloud. Here, took a linux gateway as an example, just to illustrate how it works:
After the port forwarding is set, test the port from outside computer to see if it works.
image1: get listening port
image2: add firewall rule to allow the traffic
image3: nc command
image4: port forwarding sample in the linux gateway via iptables
image5: test from outside via windows powershell (the same functionality as linux nc commad)
Regards,
Alex