Nov 15, '05 04:35:00AM • Contributed by: GlowingApple
Since I have a PowerBook and often surf the web at all sorts of places, I got to thinking of a way to do this locally. With DNS, adding a simple 'deny' entry is easy, but using someone else's DNS server usually means I don't have access to their config files.
Another way to do this is to redirect the DNS to point to a false IP address. The easy way to do this is to use /etc/hosts. By aliasing the DNS name of a site I want to block to 127.0.0.1, I can block all traffic to that site. Using sudo nano -w /etc/hosts, add the DNS names of the sites you want to block after the IPv4 localhost entry, separated by spaces.
127.0.0.1 localhost ads.site1.com ads.site2.com
255.255.255.255 broadcasthost
::1 localhost
No logout or restart is needed, just a refresh of the page. Since this blocks the site at the DNS level, this should work with any web browser.
Of course, I do not recommend using this on all ads, especially on free sites you support, since those sites most likely make a good portion of their money off of ads, thus keeping their site free! I do recommend this solution on sites with an excessive amount of ads (including pop-ups and/or pop-unders), or sites that have ads not particularly appropriate to a school or workplace environment.
[robg adds: Yes, it's easy to block ads. And yes, there are many ways to do it either within a given browser or system-wide, as shown here. And there are sites out there that take ads to the extreme, to the point where it's impossible to read the pages due to the amount of distraction one sees. But please, heed the author's advice about the sites you enjoy reading each day -- if everyone blocks ads all the time, then the future of the free web isn't necessarily good. Here on macosxhints, I don't directly make money off the ads on the site, but the ad revenue helps to pay my salary, and keeps the site (including the huge archive) free to readers. That's a good thing...]
