iptable做路由转发

本机端口影射80映射到8080
-A PREROUTING -d 127.0.0.1/32 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
-A PREROUTING -d 172.16.51.10/32 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080

转发到远程:
172.16.51.19的8480转发到10.109.9.35 61616
echo 1 > /proc/sys/net/ipv4/ip_forward
-A PREROUTING -p tcp -m tcp --dport 8480 -j DNAT --to-destination 10.109.9.35:61616
-A POSTROUTING -p tcp -m tcp --dport 61616 -j SNAT --to-source 172.16.51.19
service iptables restart
service iptables save

你可能感兴趣的:(table)