Block unwanted advertisements with /etc/hosts file on Linux

Back in the old days, before the browsers even had extensions like Adblock Plus, many of us – tech-savvy web surfers – used to block unwanted advertising, SPAM sites, and other non-sense using the /etc/hosts file.  The technology behind is very simple – you overwrite the IP address to which the unwanted website’s domain name resolves with a loopback IP address (127.0.0.1).  Whether you do it on your own machine or at a home/office proxy server is irrelevant.  And it worked magic!

Turns out, people still use this technique today.   I came across this article, which shows how to use a rather extensive list of domains for all sorts of online madness, collected and maintained by kind folks at http://winhelp2002.mvps.org/.

I tried it out of pure curiosity and sure enough it does what it says.  I’ve reverted back to Adblock Plus a couple of days later though, as random sites were breaking here and there.  I think this might be related to different adblock-detectors that many sites employ these days.  Also, some of the ads use things like embedded scripts or buttons, which might render JavaScript errors, preventing the rest of the page from loading.

But if you’ve never tried it, I strongly recommend giving it a go.

Leave a Comment