AdBlocking with Pi-Hole

tl;dr:

I replaced a bind9 virtual server with Pi-hole [1] which is awesome for adblocking and also fullfils basic local DNS needs.

Requirements

  • Something where you can run a tiny virtual machine e.g. a NAS [2]
  • A minimalistic Linux setup e.g. Debian[3]
  • The Pi-hole [1] installer
  • Access to your router to change the local DNS server

Setup your Pi-Hole

If you are re-using an existing DNS server: make a snapshot before you start. After that uninstall your existing DNS server. For bind9 it works like this:

sudo apt-get remove --auto-remove bind9

Next you’ll ensure that your system is up to date and the required curl package is installed. I know there are some discussions about installing stuff via curl, but we keep this aside here because we know what we do ;-).

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install curl
curl -sSL https://install.pi-hole.net | bash

The installer asks the main questions and adjusts the setttings of your server. When you are re-using an existing DNS server you should already have a fix internal IP address and the main settings should be all right already.

The main reason I have been using the bind9 DNS server before was the need for internal routing of domain names. The former setup was quite complicated for a very basic thing. With Pi-Hole in place its super easy to accomplish that: simply add your lines to the /etc/hosts file of your new Pi-Hole DNS server.

sudo nano /etc/hosts

# local servers
192.168.xxx.2 domain.name
192.168.xxx.3 example.com
192.168.xxx.4 sub.domain.name

As you can see in the example: subdomains are possible but wildcard domains and more sophisticated setups are not.

When you are done with the setup restart dnsmasq wit sudo service dnsmasq restart and configure your new DNS server in your ISP modem router to use this new server.

You can access a web user interface with some basic metrics and configuration via http://pi.hole/admin/. If some of your devices are already running adblocking software it might have fewer impact, like shown in the graph below.

Pi-Hole screenshot with basic metrics

Sources and Links

[1]Pi-Hole website
[2]NAS solutions from Synology or Qnap
[3]Debian installer