iptables 用法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhangchaoyi1a2b/article/details/51323155
1.
vi  /etc/sysctl.conf

net.ipv4.ip_forward = 0
改成:
net.ipv4.ip_forward = 1


sysctl -p


2.
iptables -t nat -A PREROUTING --dst 本机外网ip -p tcp -m tcp --dport 8080 -j DNAT --to-destination 转发ip:端口
iptables -t nat -A POSTROUTING --dst 转发ip -p tcp -m tcp --dport 端口 -j SNAT --to-source 本机外网ip
service iptables save
service iptables restart

猜你喜欢

转载自blog.csdn.net/zhangchaoyi1a2b/article/details/51323155