Kiriakos Krastillis's Blog

SOCKS the simple proxy solution

SOCKS, or Socket Secure, is one of those technologies that keeps coming up when You live in a world of interconnected temporary servers.

SOCKS has been tightly integrated with OpenSSH which allows you to do:

ssh -D 41337 ssh.example.com

This will add a SOCKS proxy server to your localhost port 41337 which will forward all IP traffic to ssh.example.com. Naturally only the SOCKS bound IP traffic will go that way. To showcase this let's look at the result of DuckDuckGo's MyIP tool.

curl -L --include 'http://ddg.gg/?q=my+IP&ia=answer' | grep -oE "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]"  
curl --proxy socks5h://localhost:25222 -L --include 'http://ddg.gg/?q=my+IP&ia=answer' | grep -oE "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]"  

So the first request should output Your own Public IP while the other one should return the IP of Your Proxy.

Tada. Now You are free to use any SOCKS aware application via Your personal Proxy.