Blocking ad servers on *nix machines

Here is my homegrown ad blocking solution. Put this in a text file, name it something like “block”, stick it in ~/bin.

#!/bin/sh

echo “127.0.0.1 $1″ >> /private/etc/hosts
lookupd -flushcache
tail /private/etc/hosts

Now you can sudo block ads.example.com to your heart’s content.

Of course the location of your hosts file might vary depending on your system. The above works for OS X. Also, flushing the lookupd cache is just some added sugar, on systems that don’t use lookupd the blocking will still take effect eventually.

0 Responses to “Blocking ad servers on *nix machines”


  1. No Comments

Leave a Reply




Close
Powered by ShareThis
All of mp3