Created
March 26, 2016 11:47
-
-
Save codeck/6861e0ce56ecd0680431 to your computer and use it in GitHub Desktop.
redsocks for docker container
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
cat <<EOF | |
TYPE The following commands: | |
sysctl -w net.ipv4.conf.docker0.route_localnet=1 | |
iptables -t nat -N REDSOCKS | |
iptables -t nat -A REDSOCKS -d 0.0.0.0/8 -j RETURN | |
iptables -t nat -A REDSOCKS -d 10.0.0.0/8 -j RETURN | |
iptables -t nat -A REDSOCKS -d 127.0.0.0/8 -j RETURN | |
iptables -t nat -A REDSOCKS -d 169.254.0.0/16 -j RETURN | |
iptables -t nat -A REDSOCKS -d 172.16.0.0/12 -j RETURN | |
iptables -t nat -A REDSOCKS -d 192.168.0.0/16 -j RETURN | |
iptables -t nat -A REDSOCKS -d 224.0.0.0/4 -j RETURN | |
iptables -t nat -A REDSOCKS -d 240.0.0.0/4 -j RETURN | |
iptables -t nat -A REDSOCKS -p tcp -j DNAT --to-destination 127.0.0.1:12345 | |
iptables -t nat -I PREROUTING -p tcp -i docker0 -j REDSOCKS | |
iptables -t nat -Z -L | |
sslocal -c shadowsocks.json | |
EOF | |
bash | |
sysctl -w net.ipv4.conf.docker0.route_localnet=0 | |
iptables -t nat -F REDSOCKS | |
iptables -t nat -D PREROUTING -p tcp -i docker0 -j REDSOCKS | |
iptables -t nat -X REDSOCKS | |
iptables -t nat -vL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
redir for local (instead of bridging) is trivial: