Port Redirection with IPTables on CentOS 6



  • Was struggling with this today but finally tracked down how to get this working. Most websites have this for different versions of IPTables which will not work.

    Here is what my CentOS brethren need to know. Just add this after the COMMIT line after the *filter section.

    *nat
    :PREROUTING ACCEPT [0:0]
    :POSTROUTING ACCEPT [0:0]
    :OUTPUT ACCEPT [0:0]
    -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-port 8080
    COMMIT

    Where 80 is the port external users will use and 8080 is the port your internal process is listening on.



  • Should go without saying, applies to RHEL 6 as well.


Log in to reply