John Mark Causing

System Administrator | Hosting Support Engineer

Bacolod City, Philippines

+639393497018

John Mark Causing

System Administrator | Hosting Support Engineer

Bacolod City, Philippines

+639393497018

Port forwarding from localhost/loopback

iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -t nat -I OUTPUT -p tcp -o lo --dport 80 -j REDIRECT --to-ports 8080

Screenshot below shows that the web server from localhost/loopback is using port 8080 and you cannot connect to port 80.

Screenshot below shows it can now connect to port 80 because iptables redirect (iptables requires the OUTPUT if you are using loopback/localhost)

Port forwarding connecting to a different server.

Screenshot below shows a specific web server (separate server) shows it accepts port 8080 and not port 80

Screenshot below shows it can now accept port 80 using iptables redirect

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