歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux技術 >> iptables 用法

iptables 用法

日期:2017/3/3 13:48:14   编辑:Linux技術

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

Copyright © Linux教程網 All Rights Reserved