Skip to content

Instantly share code, notes, and snippets.

@SakiiR
Last active September 28, 2018 10:01
Show Gist options
  • Save SakiiR/ff1053d604927c490dca66780abda094 to your computer and use it in GitHub Desktop.
Save SakiiR/ff1053d604927c490dca66780abda094 to your computer and use it in GitHub Desktop.
Redirect all traffic from port to ip:port
#!/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