Skip to content

Instantly share code, notes, and snippets.

@aa65535
Created December 24, 2014 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aa65535/0354bef0c7b57d90a72a to your computer and use it in GitHub Desktop.
Save aa65535/0354bef0c7b57d90a72a to your computer and use it in GitHub Desktop.
SHADOWSOCKS DNAT
iptab_r() {
local LOCAL_IP BODY
LOCAL_IP=$(uci get network.lan.ipaddr 2>/dev/null)
BODY=$(echo -e "$IPLIST" | \
awk '$1 ~ /^([0-9]{1,3}\.){3}[0-9]{1,3}/ \
{printf("-A SHADOWSOCKS -d %s -j RETURN\n", $1)}')
iptables-restore -n <<-EOF
*nat
:SHADOWSOCKS - [0:0]
$BODY
-A SHADOWSOCKS -p tcp $EXT_ARGS -j DNAT --to-destination $LOCAL_IP:$LOCAL_PORT
-A PREROUTING -p tcp -j SHADOWSOCKS
COMMIT
EOF
exit $?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment