Hi.

If you live in Portugal, you’re probably familiar with the court order for ISP’s to block The Pirate Bay. This is not the solution the the piracy problem, so I’m going to share a way to circumvent this that will (probably) work for other websites that get blocked.

What’s really happening?

When you type an address into your browser, it makes a request to a Domain Name Server (DNS) to translate the words you typed into an IP address. This is analogous to calling the information services and asking “What’s John’s phone number?”. They reply “John’s phone number is 867-5309”.

With this website blocking mechanism, the ISP’s DNS just alters the response to something else, redirecting you to a generic page that tells you the website is blocked. The obvious solution is asking someone else (changing your DNS to Google’s or OpenDNS’s, for instance), or using something that hides your traffic from your ISP (these are called VPN’s – Virtual Private Networks – and while some are free, the best are paid for) so that they have no idea that you’re requesting John’s phone number (or The Pirate Bay’s IP address).

I’ve been using Google’s DNS for a long time, and was surprised that even with it in use, I still got the blocked web page. This means that they’re effectively scanning for DNS requests and meddling with our access. So, what do we do?

Hosts file to the rescue!

Before making a DNS request, your computer (or phone, or tablet) looks for exceptions on a file called the hosts file. This file translates domains (twitter.com or thepiratebay.se) to IP addresses, and has precedence over DNS requests. This means that if you add an entry for The Pirate Bay on your hosts file, it won’t make a DNS request and you’ll be able to access blocked websites without using VPN’s or proxies. I’ll be using Windows for the rest of this post, but Mac OS X and Linux are very similar, and you should have no problem doing it on those platforms. Here’s what you need to do:

Find out what is the actual IP of the website you’re trying to access. You can use pages like this one to get it. We see that one of The Pirate Bay’s addresses is 108.162.193.114. Open your hosts file with elevated privileges. This is a system file, so you need to edit it as a system administrator to be able to save it. the easiest way is to search for Notepad on the Start Menu (or Start Screen, if you’re on Windows 8), right click it, and choose “Run as administrator”. Then go to File -> Open, go to C:\Windows\system32\drivers\etc and open the hosts file. If it doesn’t show up, change “Text Documents” to “All files” right above the Open/Cancel button. Add the entry and save it. Add a new line to the file. then, paste the IP address you got earlier, type a space, followed by the domain you want to redirect to that IP. In this case, you should add:

108.162.193.114 thepiratebay.se

After this, all you need to do is save the file and try to access your blocked website to see if it works. It should work, but if it doesn’t, try rebooting.

I’ll see you soon.