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

Tue Jun 21 15:16:03 UTC 2016
Alexander Dalloz <ad+lists at uni-x.org>

Am 2016-06-21 16:58, schrieb Always Learning:
> On Tue, 2016-06-21 at 15:46 +0100, Always Learning wrote:
> 
>> On Tue, 2016-06-21 at 16:24 +0200, Alexander Farber wrote:
>> 
>> > *nat
>> > :INPUT ACCEPT
>> > :OUTPUT ACCEPT
>> > :PREROUTING ACCEPT
>> > :POSTROUTING ACCEPT
>> > -A PREROUTING -p tcp --dst 144.76.184.154 --dport 8080 -j REDIRECT
>> > --to-port 80
>> 
>> http://www.karlrupp.net/en/computer/nat_tutorial
>> 
>> # IMPORTANT: Activate IP-forwarding in the kernel!
>> 
>>    # Disabled by default!
>>    $> echo "1" > /proc/sys/net/ipv4/ip_forward
>> 
>> ~~~~~~~~~~~~~~~
>> 
>> Is that a solution ?
> 
> and this ?
> 
> 
> # TCP packets from 192.168.1.2, port 12345 to 12356
> # to 123.123.123.123, Port 22
> # (a backslash indicates contination at the next line)
> 
> iptables -t nat -A POSTROUTING -p tcp -s 192.168.1.2 \
>      --sport 12345:12356 -d 123.123.123.123 --dport 22 [...]

Both hints are irrelevant in his case.

He needs port redirection by letting iptables rewrite the TCP header 
destination port. There is no IP forwarding of the kernel involved. 
Neither does he need to do full DNAT (or whatever the incomplete cited 
rule should do; it lacks a target directive).

Alexander