Last active
September 28, 2018 10:01
-
-
Save SakiiR/ff1053d604927c490dca66780abda094 to your computer and use it in GitHub Desktop.
Redirect all traffic from port to ip:port
This file contains hidden or 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
#!/bin/sh | |
echo 1 > /proc/sys/net/ipv4/ip_forward | |
iptables -F | |
iptables -t nat -F | |
iptables -t nat -X | |
iptables -X | |
for PORT in 80 22 8080 ; do | |
echo "Forwarding $PORT" | |
iptables -t nat -A PREROUTING -p tcp --dport $PORT -j DNAT --to-destination 192.168.128.128:$PORT | |
iptables -t nat -A POSTROUTING -j MASQUERADE | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment