I have a home router which uses NAT for the home network. I have a debian 10 machine on it on IP
192.168.0.60 that is listening to port 5000 via a small web application. I would like to be able to access this port from the public internet.
curl localhost:5000 yields the correct response.
From my mac,
curl 192.168.0.60:5000 yields the correct response.
To open it to the internet, I configured the router to port forward
5000 -> 192.168.0.60:5000.
However, when I use
curl $PUBLIC_IP:5000 from an external device (i.e. not in the network), I do not get anything. https://www.yougetsignal.com/tools/open-ports/ also yields port closed.
My first guess is that this would be a trivial port forwarding issue on the router. To rule out this situation, I did the following:
- ran the same application on my mac, listening to 5000
- changed the port forward rule on the router to
5000 -> 192.168.0.55:5000(my mac)
- used https://www.yougetsignal.com/tools/open-ports/ to validate that the port becomes open
I.e. this rules out the router, and puts the culprit on the debian machine. And at this point I am lost: how come that I can curl it from my local network and not from the internet?
The iptables reads:
root@debian# iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination