Ad-Blocker Not Required – Hosts File

Ad-Blocker Not Required - Hosts File

Note: Keep in mind that if the computer being used is pretty quick not a lot of difference is going to be seen blocking advertising. Also keep in mind that some our favorite sites need support from advertising and that news will come in advertising as well.

Update: Thanks to Ikem for finding the new script download (it is included at the bottom of the page). Also I want to not that I don’t use this method anymore and use Ad-block instead. The reason? Ad-block not does smart ad-blocking which is nice and I discovered that the addresses get stored bash’s cache with can slow bash up good.

One of the most used and handy features about Firefox is it Ad-blocker extension. As people and companies recklessly graffiti our Internet like a NASCAR Ford, it can be a strain on the eye as well as some pretty long download times. Ad-blocker does a good job but one can also use the hosts file.

Linux, Windows and Macs all have support for a hosts file. A hosts file is a list of resolved DNS addresses (IPs). By substituting the local loopback IP ( to known spammers addresses the hosts file can be used to filter out said domains.

Luckily for us, we don’t have to enter lists of spammers addresses (there are a few) but that a group of users are already involved doing it. The hosts files project have created a list of known spammer and advertising IP’s to enter into the hosts file. For Linux users, the process is very simple to add these IP’s to the hosts file. Look to the end of the page to the blog for the script. Here is a Linux script that can update the hosts file automagically. The dos2unix application will need to be installed to convert the text properly.

Support the project is encouraged. Put new IP of spammers in the hosts file and upload the hosts files to the project.

Reportedly as I saw on the Ubuntu forums the localhost address should be replace with a null-one as will wait for a timeout. This can be done by doing:

sudo sed -i 's_127.0.0.1_0.0.0.0_g' /etc/hosts

and then edit the file manually to change the line with localhost in it to localhost as this is needed.

About Gen2ly

<3's linux

Posted on 2008-02-28, in Gentoo, Linux. Bookmark the permalink. 7 Comments.

  1. Good stuff, Dirk :)

  2. “It contains list of IP’s that the source pc disallows information from.”

    This isn’t an accurate statement. The host file contains a list of names and their corresponding IP addresses, think DNS. So the host file is a way for your system to resolve names to IP addresses.

    The ability to block via the host file is by setting a given name to which is your system so your system will resolve the ad to your system instead of the adserver.

  3. Ahhhhh – nixed.

    thanks java

  4. I’ll just stay with AdBlock Plus on my firefox. Banning IP’s might cause some issues… plus I’m perfectly happy with adblock as it is.

  5. The link to the ad-blocker script is broken.

    I found another one here.

  6. @ Ikem

    … script [link] is broken.

    I found another one…

    Good work Ikem, appreciate the effort. Updated blog.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 58 other followers

%d bloggers like this: