Port Mapping on Linux

Mapping port 80 to inner port 8080:
/sbin/iptables -t nat -A PREROUTING -i eth+ -p tcp –dport 80 -j REDIRECT –to-port 8080

Well, I use this trick to avoid firewall blocking.

For binding more HTTP servers on different server implementations:

/sbin/iptables -t nat -A PREROUTING -i eth+ -p tcp -d xxx.xxx.xxx.xxx –dport 80 -j REDIRECT –to-port 8080
8080 is another server implementation’s listening port

This entry was posted in Tricks. Bookmark the permalink.

3 Responses to Port Mapping on Linux

  1. Curt Lee says:

    # iptables -t nat -A PREROUTING -i eth0 -p tcp -dport 80 -j REDIRECT -to-port 8080
    Bad argument `80′
    Try `iptables -h’ or ‘iptables –help’ for more information.

  2. KC says:

    The dport and to-port parameters require two dashes on the command line:

    e.g.

    –dport 80 ….. –to-port 8080

  3. higkoo says:

    除了Iptables还有其它方案吗?