Redirecting all your traffic though ssh for the lazy (1 copy paste) – Debian / Ubuntu

As root, copy paste the following to your terminal:

apt-get -q -y install git $(apt-cache search libevent | grep ^libevent-dev | sort | head -n1 | awk '{print $1}')
git clone http://github.com/darkk/redsocks.git
cd redsocks/
make
echo 'base{log_debug = on; log_info = on; log = "file:/tmp/reddi.log";
daemon = on; redirector = iptables;}
redsocks { local_ip = 127.0.0.1; local_port = 60001; ip = 127.0.0.1;
port = 60002; type = socks5; }' > redsocks.conf
./redsocks -c redsocks.conf
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 REDIRECT --to-ports 60001
iptables -t nat -A OUTPUT -p tcp -j REDSOCKS
echo -n "Enter Your Username: ";read myusername;echo -n "Enter Your SSH server hostname/IP: ";read sshhostname; ssh $myusername@$sshhostname -N -D 60002

Share on FacebookTweet about this on TwitterShare on Google+Share on StumbleUponShare on RedditShare on TumblrShare on LinkedInEmail this to someone