Forward traffic from 80 to 8080

Its very simple to Forwarding traffic from 80 to 8080 using iptables

First make find the entry from ifconfig

 

[[email protected] httpdocs]# ifconfig 
em1 Link encap:Ethernet HWaddr F8:B1:56:AF:77:09 
 inet addr:85.25.211.175 Bcast:85.25.211.191 Mask:255.255.255.192
 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
 RX packets:15624634 errors:0 dropped:0 overruns:0 frame:0
 TX packets:7522042 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000 
 RX bytes:21012361670 (19.5 GiB) TX bytes:625245756 (596.2 MiB)
 Interrupt:20 Memory:f7c00000-f7c20000
lo Link encap:Local Loopback 
 inet addr:127.0.0.1 Mask:255.0.0.0
 UP LOOPBACK RUNNING MTU:16436 Metric:1
 RX packets:82731 errors:0 dropped:0 overruns:0 frame:0
 TX packets:82731 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:0 
 RX bytes:74317559 (70.8 MiB) TX bytes:74317559 (70.8 MiB)

 

Here its em1 so add the entry

iptables -A PREROUTING -t nat -i em1 -p tcp --dport 80 -j REDIRECT --to-port 8080

Now traffic to 80 will be forwarded to 8080