Expat tips: Tunneling Traffic with ‘ssh -D’
I’ve been living outside the US for over a quarter of my life now. With this comes some minor annoyances. One annoyance is that certain Internet sites work ‘better’ when connecting from the US. Luckily we can easily make it look like we are connecting from a US location with the help of the following.
- A US-hosted server with ssh access
- A browser
- ssh
I’ll assume you have the last two. The easiest way to get the first is in the form of a web host. I use Dreamhost which offers unlimited bandwidth for a pretty good price.
The first step to getting things to work is to login to the US-based server using the following command.
ssh -D PORT_NUMBER username@example.com
For the port number, it’s best to choose a number between 1024 and 49151 while avoiding any commonly used ports. Basically, avoid those listed here. In this example, I chose port 8421.
What this does is setup a SOCKS proxy on your local machine at the port given that can be used to tunnel traffic through to a remote machine, in our case a US-based server. Obviously, this connection needs to be maintained the entire time you want to send traffic through to the remote machine.
Now we just need to tell our browser to send all traffic through this port. In Firefox, go to Edit->Preferences->Advanced->Network->Settings. You should be presented with a window similar to this…

You’ll notice the 127.0.0.1 (localhost works too) and 8421 in the SOCKS host fields. That’s all that’s required. If you later want to revert just chose ‘No Proxy’ again.
Now you can close the preference dialog and should be able to enjoy surfing the Interwebs as an American. Fuck yeah!







