Created
May 23, 2014 14:55
-
-
Save dsabanin/e53abc60fe8d7136d5a1 to your computer and use it in GitHub Desktop.
Script for setting up redirect for a local port to a remote host's port (root or sudo needed)
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
#!/bin/sh | |
TARGET_HOST=9.9.9.9 | |
TARGET_PORT=22 | |
PROXY_PORT=23 | |
echo 1 > /proc/sys/net/ipv4/ip_forward | |
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport $PROXY_PORT -j DNAT --to $TARGET_HOST:$TARGET_PORT | |
iptables -t nat -A PREROUTING -p tcp --dport $PROXY_PORT -j DNAT --to $TARGET_HOST:$TARGET_PORT | |
iptables -t nat -A POSTROUTING -p tcp -d $TARGET_HOST --dport $TARGET_PORT -j MASQUERADE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment