Skip to content

Instantly share code, notes, and snippets.

@zhangchenchen
Created July 28, 2017 01:42
Show Gist options
  • Save zhangchenchen/d1c50c0774868dc73553838322e40305 to your computer and use it in GitHub Desktop.
Save zhangchenchen/d1c50c0774868dc73553838322e40305 to your computer and use it in GitHub Desktop.
## remote forward ##
iptables -t nat -A PREROUTING -d LocalIP -p tcp --dport PortNumber -j DNAT --to-destination DestinationIP:Port
iptables -t nat -A POSTROUTING -d estinationIP -p tcp --dport PortNumber -j SNAT --to-source LocalIP
## local forward ##
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -t nat -A OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j DNAT --to 127.0.0.1:8080
iptables -t nat -A OUTPUT -p tcp -d 192.168.1.17 --dport 80 -j DNAT --to 127.0.0.1:8080 # 192.168.1.17 is localIP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment