So a few days ago we needed to do a port redirect on a server. This was a new implementation of an app server, but the link for all the clients refered to port 80. The new install listed on port 8080.
A few ideas were kicked around like installing apache to listen and do a metaredirect to the new location. Then it clicked, why not use IPtables?
Below is how we redirected port 80 to 8080
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080
Once completed and tested, I saved the config as follows
iptables-save > /etc/sysconfig/iptables
The above is for a RedHat Linux server. IPtables pulls its config from /etc/sysconfig/iptables file on startup.
Filed under: Linux, Networking
