iptables: forward port 80 to port 8080
You cannot specify the table like that in/etc/sysconfig/iptables
. Each table is set with an asterisk then the table name. Here is a skeleton of what you'd do:
*nat
:PREROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination :8080
COMMIT
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
COMMIT
Instead of editing the file you could also manually set up the rules you like using the iptables
command and then execute iptables-save > /etc/sysconfig/iptables
or service iptables save
.
you were close
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination :8080
It has to do NAT so that when the reply is sent back to the client, it appears to come from port 80, not 8080.