You know those ads that take over your entire screen? Or the ones that intrusively play music, alerting everyone around you that you've visited a website that is probably not work-related? How about those ads that leave behind tracking cookies so they can monitor your internet surfing behavior? These are the ads that make you scared to surf the internet. Fortunately, you can avoid them.
Ad blockers are among the most popular browser extensions around. But if you use several browsers on several PCs, keeping everything in sync and installing all those plug-ins can be a pain, especially when you could be blocking ads at a higher level.
It's not hard to block ads long before they reach your browser, you just need to set up an IP-blocking list (the same technology your browser-based blocker is using) either on your PC or through your router.
This tutorial will give you a basic overview of how to set up your own global ad-blocking system for your entire network.
This guide to blocking ads is part of Wired's How-To Wiki. You may be asking yourself why we're showing you how to block ads, even though ads help pay our salary. Why don't you answer the question for us; contribute to this article or the wiki at large.
On your PC or Mac
The secret to blocking ads for any browser on your system is to do the blocking at the OS level. This means altering a file known as the hosts file.
A hosts file contains mappings of IP addresses to host names. When your computer starts up it loads the hosts file into memory and checks with this file before sending requests on to a web server.
To create an ad blocker, you simply need to add some rules to your hosts file. (Doing this may disable some other functions of web pages, such as certain embedded videos that normally begin with an ad, etc.)
On Windows the host file lives here:
On Mac OS X and Linux it's generally here:
Tip: On Linux or Mac OS X, you can go straight to this folder from a Terminal window using Unix/Linux commands. If you use Mac OS X and you're unfamiliar with the command line, the easiest way to get to the file is to press Shift-Command-G (or select Go To Folder... from the Finder's Go menu). Pasteprivate/etc/hosts into the field and submit. The easiest way to edit the file is to drag it from the finder to the desktop and edit with Text Edit, save it to the desktop, and drag it back - at which point it will ask you to authenticate with your administrative password. This is easier than using pico or nano, as it is a very long file.
Once you find your host file, open it using any text editor and then add the rules for sites you'd like to block.
Of course, figuring out where ads are served from is a cumbersome task, Fear not, others have already done the hard work for you. One of our favorites is the MVPs.org hosts file, just copy the contents into your hosts file, save and enjoy your new ad-free web.
Using a router
An even more efficient way to block ads is at the router level. Install an ad-block script on your router, and any computer connected to your home network won't be served ads.
Understandably, most routers don't contain tools to block any sort of content (even ads) out of the box. However, open firmware tools, like DD-WRT or Tomato, make it pretty simple to set up a network-wide ad blocking system.
If you're using the Tomato firmware head over to the Tomato-suggested forums where users have already contributed their own scripts along with instructions on how to install them. Just download the scripts, copy them to your router and you're done.
For DD-WRT fans, check out this wiki post which contains several scripts and links you can use with your DD-WRT firmware.
In the future
Ad blockers are a controversial topic -- users love them, but if everyone used an ad blocker, many sites would be out of business in a hurry. We don't expect ad blockers to go away, but at some point, sites may start blocking users with ad blockers. A few already do, in fact. As with any cat and mouse game, ad servers will get more sophisticated and ad blockers will race to keep up.