My VM has set some rules for access to a web server and a SSH. The server is running in the internal port 8080 en redirected using iptables to the port 80 with the command:

iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

When i add the rule to DROP INPUT and afterwards the one for oppening the port

IPTABLES -A INPUT -p tcp --dport 80 -j ACCEPT

it doesnt work.

I have the same setup on port 4422 for the SSH server and works perfectly but not in the http one.


Chain INPUT (policy DROP)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:4422
ACCEPT     all  --  anywhere             anywhere(this one is for the lo)
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http

Prerouting takes place before INPUT, so you will need to ACCEPT from 8080, not 80.

IPTABLES -A INPUT -p tcp --dport 8080 -j ACCEPT
  • this is the solution. – Pablo Mujica Apr 11 '16 at 2:11

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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