Skip to content

Instantly share code, notes, and snippets.

@cheneyveron
Created April 17, 2019 15:12
Show Gist options
  • Save cheneyveron/4e1847a603f20c98472e8a7b695c8828 to your computer and use it in GitHub Desktop.
Save cheneyveron/4e1847a603f20c98472e8a7b695c8828 to your computer and use it in GitHub Desktop.
iptables内网转发
# 本机端口映射其他机器
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 8006 -j DNAT --to-destination 192.168.2.2:8006
iptables -t nat -A POSTROUTING -d 192.168.2.2/32 -p tcp -m tcp --sport 8006 -j SNAT --to-source 192.168.2.1
iptables -t filter -A INPUT -p tcp -m state --state NEW -m tcp --dport 8006 -j ACCEPT
# 本机端口
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 10080 -j DNAT --to-destination 192.168.2.1:80
iptables -t filter -A INPUT -p tcp -m state --state NEW -m tcp --dport 10080 -j ACCEPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment