linux iptables 公网、网关做DNAT
192.168.18.230 <-------> 192.168.18.130 192.168.11.130 <-------> 192.168.11.131
iptables -t nat -A PREROUTING -p tcp -d 192.168.18.130 --dport 2222 -j DNAT --to 192.168.11.131:22 iptables -t nat -A POSTROUTING -s 192.168.11.131 -p tcp --sport 22 -j SNAT --to-source 192.168.18.130 iptables -t nat -A PREROUTING -p tcp -d 192.168.18.130 --dport 80 -j DNAT --to 192.168.11.131:80 iptables -t nat -A POSTROUTING -s 192.168.11.131 -p tcp --sport 80 -j SNAT --to-source 192.168.18.130 echo 1 > /proc/sys/net/ipv4/ip_forward
转载于:https://blog.51cto.com/ltlwx/1642324