Reputation: 1305
I redirect port 80 to port 8000 via:
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8000
The other host can access my webserver via 80 port, but the redirection cannot work in local host when I access 127.0.0.1:80.
Can port direction work for loopback network adapter?
Upvotes: 5
Views: 7110
Reputation: 409176
The nat
table is used for Network Address Translation, and is only used for external interfaces. You have to add the rule to a table that handles internal communication as well.
Upvotes: 3