For years we had an internal server running FreeBSD and a Bind config for the mere purpose of doing the internal DNS. Apart from being authoritative for one mockup-domain which contains all the sites for on our development server it was also running fake zones for many advertisement servers.
About a week ago the motherboard of this server died on me, for unknown reasons the board fails to powerup. The powerled is on but everything else fails. You will notice the smell of burning electronics in seconds when powered up. In that same amount of time the W83627DHG runs too hot to touch.
Exit server; as most of the stuff was migrated to other machines I thought we could manage well without it.
Until those nagging banners popped up in browsers not running ad-blockers. Nothing is more frustrating than the lag and slowness of a page loading too many ads from too many adservers.
We really needed the DNS blackhole back.. And as it happened there was a Raspberry Pi collection dust.
Inspired by http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0/#alternatesources I installed the Raspian OS and got to work.
Instead of running the “canned solution” which includes running a fake web server I decided to mimic my old Bind setup. However instead of bind I used PowerDNS instead, installing it on a Pi is as simple as:
apt-get install pdns-server
Add a file containing:
launch+=bind bind-config=/etc/powerdns/bindbackend.conf bind-config=/etc/powerdns/adservers.conf
/etc/powerdns/pdns.d and enabling the recursor in
pdns.conf and most of the config is done.
The solution by Jacob Salmela includes a shell script which fetches lists of known adservers from various places. On the old server I only used one: http://pgl.yoyo.org/adservers/serverlist.php and it worked fine but adding more known-bad servers is always good.
Ever since the eighties I cringe when I need to read through shell code. The only thing I took from the script is the list of servers. The rest I re-implemented in Python, it all had to change for the PowerDNS setup I had planned anyway.
The script gets the list from all the URL’s in the sources