Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Socks proxy to connect private hosts with circleci
- docker
- wget ~/ && chmod +x ~/
- ~/ start:
background: true
#!/bin/bash -x
set -e
function tunnel_up(){
sudo apt-get install redsocks -y
ssh -o StrictHostKeyChecking=no -v user@cmyhost -22 -i ~/.ssh/my-private-key -D 9999 -nf "sleep 90000" &
echo 'base{log_debug = on; log_info = on; log = "file:/tmp/reddi.log";daemon = on; redirector = iptables;}redsocks { local_ip =; local_port = 12345; ip =;port = 9999; type = socks5; }' > ~/redsocks.conf
sudo redsocks -c ~/redsocks.conf &
sudo iptables -t nat -N REDSOCKS
sudo iptables -t nat -A REDSOCKS -p tcp -d -j DNAT --to
sudo iptables -t nat -A OUTPUT -d -j REDSOCKS
sudo iptables -t nat -I PREROUTING 1 -d -j REDSOCKS
if [ $1 == "start" ]; then
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment