carlynorama

the blog

Using the hosts file to kill Hulu and save your life.

by Carlyn Maw on December 6, 2009, no comments

So I don’t own a TV. I don’t own a TV the way an alcoholic doesn’t keep vodka in the freezer.  When I’m at my most stressed sinking into the story of someone else’s life is better than crack.  Hulu.com’s putting of everything on the computer… well, I can feel Alec Baldwin’s finger checking my ear like in the commercial and it is, not, not good. (Shudder) My counter attack is to destroy my computers ability to see any of that gooey lovely time drain. 

This is where the hosts file comes in. Quoting “Cisco Networking Academy Program: First-Year Companion Guide” via Wikipedia:

“The hosts file is a computer file used by an operating system to map hostnames to IP addresses. This method is one of several methods used by an operating system to locate network nodes on a computer network. On many operating systems, the host file content is used preferentially over other methods, such as the Domain Name System (DNS). Unlike DNS, the hosts file is under the control of the local computer’s administrator.”

Translation: Every website has its real location on the network, its phone number if you will, called an Internet Protocol (IP) address.  There is a big contact-book called the DNS system that puts in names for addresses.  You can change your computer’s local copy of that contact list for specific sites through the hosts file.

There are a lot of practical ad-killing, malware busting applications for this. Checking the cookies in your browser reveals all sorts of web addresses you never knew you “visited” because the web pages you’ve gone to have loaded in ads and plug-ins, etc, that aren’t hosted on their own servers.  Once you know how to block one, you can block whatever you like.

The steps are as follows:

  1. Pick a new IP to see instead
  2. Open & edit your Hosts file
  3. Save / Reboot

Picking a new IP

There are some options for this.

  • If you are running your own server, locally or otherwise, you know an IP you can use already that has custom content on it and everything.
  • You can also look up the IP addresses of any website you like using a service like ip-lookup.net‘s domain look up tool.  There are lots of these services that do checks (whois.net, for example ) but I like ip-lookup.net because there is nothing blinking on the pages or up sells for reports, etc.   Keep in mind if the website you choose “changes its phone number” by the company or organization moving where it hosts it website you will need to manually update your hosts file again to reflect the new address.
  • Another option is a “dead” IP like 0.0.0.0 or 255.0.0.0 which just go nowhere.

I’m going to pick Ad Busters at 67.192.229.58 for now.

Find & open your hosts file

Again wikipedia to the rescue… there is a nice little table there for a number of platforms. I’m on Mac OS X so the location of the file is /private/etc/hosts

To open and edit this file there are a couple of choices. I own a copy of BBEdit so I can open that and use the Open By File Name option (⌘D) and paste the location there. BBEdit is great because it will let you change files that belong to the system without doing something called “logging in as the root user”. If you don’t have something that will let you edit system files on your computer, then this gets a bit trickier, and the direction here are going to get very Apple specific.

  • Follow the directions enable your root user: Apple KBase on Root User
  • Re log-in as the root (user name “root”, password the one you just made, root won’t be listed as one of the users, you may have to select “Other” or something like that)
  • Open TextEdit in the Applications folder
  • Select File > Open
  • There should be a search bar in the top right corner of the window that will actually let you type in the path to the hosts file, type the path starting with the forward slash.
  • Make sure the hosts file is highlighted and hit Open

However you got here, you should see something like this: