I'm having difficulties accessing a listening service (Ionic) on port 8100 from a remote browser.
I have iptables on the Ubuntu 16.04 LTS server set up as following:
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -s 127.0.0.0/8 ! -i lo -j REJECT --reject-with icmp-port-unreachable
-A INPUT -p icmp -m state --state NEW -m icmp --icmp-type 8 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -m state --state NEW -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables_INPUT_denied: " --log-level 7
-A INPUT -j REJECT --reject-with icmp-port-unreachable
-A INPUT -p tcp -m tcp --dport 8100 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m tcp --dport 8100 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
-A FORWARD -m limit --limit 5/min -j LOG --log-prefix "iptables_FORWARD_denied: " --log-level 7
-A FORWARD -j REJECT --reject-with icmp-port-unreachable
-A OUTPUT -p tcp -m tcp --sport 8100 -m state --state NEW -j ACCEPT
-A OUTPUT -p tcp -m tcp --sport 8100 -m conntrack --ctstate ESTABLISHED -j ACCEPT
After this didn't work, I tried to add rules with UFW:
Status: active
To Action From
-- ------ ----
8100 ALLOW Anywhere
8100/tcp ALLOW Anywhere
8100 (v6) ALLOW Anywhere (v6)
8100/tcp (v6) ALLOW Anywhere (v6)
I still get ERR_CONNECTION_REFUSED
when I try to access this port from a remote browser. Port 80 and 22 works as normal.
As the for the service itself on port 8100, I have tried have it listen as follows:
dev server running: http://localhost:8100/
and:
dev server running: http://<my server's IP>:8100/
Which results in the same error.
Edit, When I run $ ss -ltnp "src :8100"
:
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 <server's IP address>:8100 *:*
edit 2, Also tried to make it listen as follows:
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:8100 *:*
Best Answer
With iptables the first match wins, so,
Everything below that line in the INPUT will be rejected and you will get a Connection Refused message
Look what's below it
Q.E.D.