I'm trying to give public access from outside my network to a specific device ( inside my network, using port 5000.

I have a PC acting as a firewall between my gateway and the devices inside my network, so I need to change that PC's iptables. That PC acting as firewall has two interfaces: eth0 ( and eth1 (

The incoming traffic from outside will come from eth1 ( and I just need to forward it to eth0 ( because, at the moment, I've already set the forwarding from to (the final device) and it's working fine.

Searching on the web, I tried to set the next two iptables rules, without success:

iptables -A FORWARD -p tcp --destination-port 5000 --in-interface eth1 -j ACCEPT
iptables -t nat -A POSTROUTING -p tcp --destination-port 5000 --out-interface eth0 -j MASQUERADE

Then, I tried to set the next iptables rule, also unsuccessful:

iptables -t nat -A PREROUTING -p tcp --destination-port 5000 --in-interface eth1 -j MASQUERADE

In conclusion, if I type in a browser from inside my network, I can access, so that forwarding is working fine. But if I type in a browser my.public.i.p:5000 from outside my network, I get an ERR_ADDRESS_UNREACHABLE, so the forwarding between eth1 and eth0 is not working fine.

Some help will be appreciated. Thanks.


Are you aware, that both and are private segments and therefore unreachable from the Internet? If your "router" has the IP, it's on the internal network already. The external IP will be something else and the border router must be able to route all traffic from outside of the Internet to your internal IP to be able to reroute the port. If it's firewalling incoming traffic, than you can't get any packet on port 5000 from the Internet.

  • Thanks Jaroslav. is eth1's IP, the border router has the IP Are you sure there's no way to forward the traffic from the Internet? – Albert Oct 24 '17 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.