Skip to content

Instantly share code, notes, and snippets.

@maulvi
Forked from codeck/redocker.sh
Created November 25, 2020 13:54
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 maulvi/399659af2762cfac4065d4fb30351c5b to your computer and use it in GitHub Desktop.
Save maulvi/399659af2762cfac4065d4fb30351c5b to your computer and use it in GitHub Desktop.
redsocks for docker container
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