Last active
January 27, 2016 10:17
-
-
Save seanhsu0102/a4040fd58413703f23c4 to your computer and use it in GitHub Desktop.
iptables foward port to other IP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```bash | |
# 啟用 IP forward 預設為 0 = off 避免被當跳板 | |
$ echo '1' > /proc/sys/net/ipv4/ip_forward | |
# 把你要導的 port 導到想導的 IP:PORT 去 | |
$ iptables -t nat -A PREROUTING -p tcp --dport 443 -j DNAT --to-destination 192.168.1.1:443 | |
# 使用你的外部 IP 當做 forward 出去所看到的 PORT | |
$ iptables -t nat -A POSTROUTING -j MASQUERADE | |
# 清空 iptable NAT規則 | |
$ iptables -t nat -F | |
# 請小心使用避免你自己被關在 server 外永遠進不去 | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment