Block ads at home using Pi-hole and a Raspberry Pi

Today’s blog post comes from Jacob Salmela, creator of Pi-hole, a network-wide ad blocker used by Raspberry Pi enthusiasts to block advertisements on all devices connected to their home network.

What is Pi hole?

An explainer video about the network-wide ad blocker and how to install it.

What is Pi-hole?

Pi-hole is a network-wide ad blocker. Instead of installing adblockers on every device and every browser, you can install Pi-hole once on your network, and it will protect all of your devices. Because it works differently than a browser-based ad-blocker, Pi-hole also block ads in non-traditional places, such as in games and on smart TVs.

I originally made Pi-hole as a replacement for the AdTrap device. I have a background in networking, so I figured I could make something better with some inexpensive hardware like the Raspberry Pi. I spent two summers working on the project and made the code open source. Four years later, we have several developers working on Pi-hole, and we have grown into a very large project with a vibrant community.

How does it work?

Pi-hole functions as an internal, private DNS server for your network. For many home users, this service is already running on your router, but your router doesn’t know where advertisements are — but Pi-hole does. Pi-hole will intercept any queries for known ad-serving domains and deny them access, so ads won’t be downloaded.

Using Pi-hole on a Raspberry Pi

Users configure their router’s DHCP options to force clients to use Pi-hole as their DNS server.

This means websites will load normally but without advertisements; since ads are never downloaded, sites will load faster. Pi-hole also caches these queries, so responsiveness to commonly visited websites can also be noticed.

Pi-hole and Raspberry Pi

The Pi-hole software has very low resource requirements and can even run on a Raspberry Pi Zero W. And despite its name, you can also install Pi-hole on several other Linux distributions. Many users install it on a VM or in a container and let it provide services that way. But since Pi-hole’s resource requirements are so low, many users have found it to be a good use of their older, lower-powered model Raspberry Pis. Simply install Pi-hole, connect the Pi to your router, and begin blocking ads everywhere.

Using Pi-hole on a Raspberry Pi

The Pi-hole web interface allows users to monitor ad-blocking data, to access the query log, and more.

You can also pair Pi-hole with a VPN to get ad blocking via a cellular connection. This will help you with bandwidth limits and data costs, because your phone won’t need to download advertising videos and images.

Install Pi-hole

Pi-hole can be downloaded to your Raspberry Pi via a one-step automated install — just open a terminal window and run the following command:

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

You can find more information about setting up Pi-hole on your Raspberry Pi on the Pi-hole GitHub repository here.

If you need support with using Pi-hole or want to chat with the Pi-hole community, you can visit their forum here.

If you’d like to support Jacob and the Pi-hole team as they continue to develop the functions of their ad-blocker, you can sign up as a Patreon, donate directly, or purchase swag, including the Pi-hole case from Pi Supply.