IPtables端口转发

场景:

在Linksys路由器上使用DDwrt。 我想使用IPtables将特定的公共IP地址端口转发到内部IP 192.168.0.20端口80。 不知道如何做到这一点,将不胜感激。

就像是:

iptables -t nat -A PREROUTING -d <public-ip> -i <wan-interface> -j DNAT --to 192.168.0.20 

应该pipe用。 如果您只想在公网IP上转发TCP端口80,则可以执行以下操作:

 iptables -t nat -A PREROUTING -p tcp --dport 80 -d <public-ip> -i <wan-interface> -j DNAT --to 192.168.0.20:80