Monday, December 26, 2011

TSocks with Ubuntu Linux

So it turned out that a simple SSH Tunnel doesn't always accomplish what is needed.  An SSH Tunnel is great for applications that are able to redirect their own packets to a different proxy, but what about applications that don't natively support proxies?

One alternative is to use a VPN Tunnel, in most cases this will work great, but in some networks VPN packets are restricted.  Also VPN networks doesn't typically run on natively installed software.  To solve this issue I turned once again to Linux which seems to have the best collection of geeky programs natively installed.

Step 1: I downloaded VirtualBox which is an OS simulator.
Step 2: I downloaded an ISO file of Ubuntu linux.
Step 3: Download the tsocks .deb file, you may need a normal SSH tunnel if web traffic to that site is being blocked:
   Go to this website, scroll to the very bottom, and click on the link for the correct version of linux and 32 vs 64 bit OS.
   Under the Download Mirrors section click on "select mirror".
   Click on the binary package link to download the .deb file.
Step 4: Install the tsocks .deb file.
Step 5: Edit the tsocks file, first rename the default file then modify the original file.
   sudo mv /etc/tsocks.conf /etc/tsocks.conf.old
   sudo nano /etc/tsocks.conf
Step 6: Add the following two lines to the file:
   server =
   server_port = 6060
   these lines tell tsocks to redirect all traffic fed through it to the local loopback ip using port 800.
Step 7: Start up a ssh session accepting traffic on the port that tsocks is now configured to send it on.
   ssh -C -D6060 -v -v
   The -v -v are two levels of verbose troubleshooting, you only need to use them if you want to watch what is happening inside the tunnel.
Step 8: Open another command prompt, and startup a firefox session through tsocks. I used firefox simply because it is a decent browser and is the default one installed on linux. Use the following command at a command prompt.
   sudo tsocks firefox

With this setup all firefox's child processes should be tunneled through the tsocks connection as well which includes things like voice calls or video chats started from the web browser but running on different ports.  Replacing firefox with the command for other applications you can try tunneling them through the tsocks connection as well.

Steps 7 and 8 will need to be repeated every time you want to initiate the tunnel from now on.

Getting your audio, and other USB devices to work correctly through the virtual machine is a whole different issue.  If you have too many problems with this try using a regular Linux install instead of a virtual box.

No comments:

Post a Comment

Please leave your thoughts, I love hearing what you got out of the post. Spam comments will be removed.