[Raspberry Pi General] Oswald Boelcke:
The Pi-hole

Updated on 2019-03-18!

********************

The Pi-hole

The Pi-hole has been developed by Jacob Salmela since 2015. Pi-hole is based on dnsmasq and the webserver Lighttpd. The complete source code is available at GitHub. But what makes Pi-hole actually so special? It's a solution to block advertisement and trackers already within the network i.e. Pi-hole is theoretically able to blocks ads for all devices connected to the network. I guess this initially sounds adventurously but it proves to work in our home network.

If interested in the technical background please refer to the linked websites.

For the installation of Pi-hole on the Raspberry Pi, I connected to the Pi via SSH and opened a terminal. For a full automatic installation of Pi-hole I used the following command line:

curl -sSL https://install.pi-hole.net | bash

Attention: Please acknowledge the following statement posted on the Pi-hole webpage:

After completion of the installation of all packages and dependencies, the configurator opened. My personal selection is as follows:

Select Upstream DNS Provider

Custom: 85.214.20.141, 213.73.91.35 [Remark: DNS servers as already mentioned in post #2.]

Select Protocols

IPv4: Check

IPv6: Uncheck (Remark: None of our devices uses IPv6.)

Do you want to use your current network settings as a static address?

IP address: xxx.xxx.xxx.xxx (Remark: The fixed IP-addess of the Raspberry Pi.)

Gateway: xxx.xxx.xxx.1 (Remark: The IP of my router i.e. the Fritz!Box.)

Do you want to log queries?

On: Check

After the configurator's queries were completed it provided me with the address of graphical web-interface (http://pi.hole/admin or http://"IP-address of the Pi"/admin; screenshot available in the OP) and the login password for Pi-hole.

Remark: As soon as practicable I changed the initial password to my own one by following command line:

sudo pihole -a -p

In order that ads and trackers are blocked by the Pi-hole, it's necessary to point the Pi as the DNS-server to all devices. As usually, different ways and approaches exist to do so. Below I only describe the one I used.

Please refer to the attached screenshot that I already used in post #2, too. I circled the field where I inserted the IP-address of the Pi as the local DNS server.

Remark: With some routers it's possible to simply assign the IP-address of the Raspberry Pi as the new DNS-server. Advantage: Nothing is changing for the clients; they simply send a DNS-request to the router that forwards it to the Pi-hole in turn. However, this feature is not available for all Fritz!Boxes due to their integrated "DNS Rebind Protection".

Just for completeness a few useful Pi-hole commands:

pihole -h: Help that shows a list of all available commands

pihole -up: Initiates an update of the Pi-hole software

pihole -r: Relauch of the configurator e.g. to conduct changes to the DNS

pihole -g: Initiates an update of the blocklists

Pi-hole automatically updates the ad sources once a week on Sunday at a random time in the early morning. If required this "cron-job" can be changed via

sudo nano /etc/cron.d/pihole

respectively

sudoedit /etc/cron.d/pihole

Since Pi-hole version 3.x, it's no longer required to add/delete/amend blocklists via a terminal but can easily be accomplished via the Admin-web-interface.

Now some initial changes to the pi-hole settings via the Admin GUI:

Settings → DNS → DNSSEC: Enabled.

Settings → Blocklists: Set to you're own desire; I've got all default lists enabled. Personally I added the Non-crossed-list to the blocklists. Just copy and paste all lists into the text field, followed by a click onto "Save and Update".

In the dashboard, about 1M blocked domains should be indicated.

Final remark: Personally, I recognise the Pi-hole as my first line of defense, and I continue to use addons in my browser like uBlock Origin to defeat the rest.