Block Ads and Tracking With Pi-Hole

A 2020 look at the free home network solution.

Andrew Selig
4 min readJun 22, 2020
Raspberry Pi 4 with heatsinks haphazardly attached.

One of the items that has been on my list to implement as part of my 2020 commitment to taking back my digital self has been experimenting with Pi-Hole on a Raspberry Pi. This accomplishes two goals at the same time: one to deploy a local DNS server that reduces ads and malvertising, and the other to have a reason to play with the popular small form factor of the Raspberry Pi.

The first goal is the most important. As you browse the Internet, advertising companies build detailed profiles of how they can separate you from your money through the use of vast ad networks. When you simply request CNN.com, you’re really being served up ad and tracking networks with the names of Outbrain, Summerhamster, and Optimizely. As these networks are so pervasive, miscreants will use them to direct your browser to pull down malware while you are visiting a legitimate site. Both instances are annoying and something worth taking a swing at blocking.

Pi-Hole acts as a DNS resolver for your home network, so that when you type in CNN.com, your computer can translate that to an IP address so that it can request the news you’re looking for. Pi-Hole blocks traffic to ad domains so that the objects in these pages simply don’t load.

There is an argument for not blocking this type of traffic; that if the Internet runs on advertisements, which it does, the largest impact to running an ablocker is limiting the amount of money small content creators can earn through monetizing their sites. While I understand this line of thinking, the way these ad networks operate constantly put users at risk for contracting malware from pages unrelated to their original browsing sessions.

Procure a Pi

This is the easiest, although it might seem the most daunting of the steps. The Pi is famous for being an entire computer on one credit card sized circuit board. They can be used for all sorts of projects, and there are plenty of great sources (Reddit, The MagPi) that can help you out with anything you need along the way.

I went for a Raspberry Pi 4 (4GB) for this, and while it is overkill for Pi-Hole, I wanted hardware (4GB RAM) and adapters (USB-C, HDMI, USB, and Ethernet) I was more comfortable with. It also allows me to add more utilities and applications than just Pi-Hole. Making it even simpler, I paid for the CanaKit all-in-one, so that I went from an Amazon package to a running OS in about 15 minutes.

Boot Up Pi-Hole

With your RPi up and running, the install of Pi-Hole could not be easier on a Linux system. Switch your user to root, and run the one line statement from the Pi-Hole instructions GitHib page:

user@localhost$ sudo su -root@localhost# curl -sSL https://install.pi-hole.net | bash

During the installation, be sure to set a static IP for your device, something that is easy to remember.

Once you are able to log in and validate your Pi-Hole is up and running, update the DNS settings on your computer (or router’s DHCP server if you want to go all in right away) so that they point to your new DNS resolver. Be sure to add another public DNS resolver (OpenDNS: 208.67.222.222 and 208.67.220.220) in the event your Pi-Hole goes down so you don’t have problems browsing. Once updated, start browsing your favorite websites and monitor the stats in the Pi-Hole admin console.

Results over the past 24 hours

Your browser thanks you

I’ve been using it on my laptop and iPhone for the past couple of weeks and haven’t noticed much of a difference, either in a slowness of query speed (mine is still on wireless), or in the amount of broken webpages. It’s not in your face about it is improving your browsing, but I’ll take its word for it, and I’m happy with the results of 30–40% dropped requests.

So far, my steps towards limiting the amount of “me” data on the Internet has been a success, with no impact to my normal browsing, and a small hardware cost that will be put to good use for many more projects.

--

--