[CentOS] Redirecting port 8080 to port 80 - how to add in /etc/sysconfig/iptables file?

Mon Jun 20 19:09:39 UTC 2016
Alexander Dalloz <ad+lists at uni-x.org>

Am 20.06.2016 um 21:01 schrieb Alexander Farber:
> Good evening,
>
> on a CentOS 7 LAMP (not gateway) dedicated server I am
> using iptables-services with the following /etc/sysconfig/iptables:
>
>
> *filter
> :INPUT DROP [0:0]
> :FORWARD DROP [0:0]
> :OUTPUT ACCEPT [294:35064]
> -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
> -A INPUT -i lo -j ACCEPT
> -A INPUT -p icmp -m icmp --icmp-type any -j ACCEPT
> -A INPUT -p tcp -m state --state NEW -m tcp -m multiport --dports
> 25,80,443,8080 -j ACCEPT
> -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 --tcp-flags
> FIN,SYN,RST,ACK SYN -m limit --limit 2/min --limit-burst 1 -j ACCEPT
> COMMIT

[ ... ]

> # iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
>
> but I can not figure out the corresponding line for the
> /etc/sysconfig/iptables

You will be surprised how easy it is to save the current ruleset:

/usr/libexec/iptables/iptables.init save

> I have tried running the above command and then "iptables -S" to see the
> added rule, but that didn't really work.
>
> Thank you
> Alex

Regards

Alexander