Advertisements are one of the biggest annoyances while browsing the internet. One popular way to eliminate them is by installing the Google Chrome extension uBlock Origin. This extension works great, but it only works inside of Google Chrome. The explosion of IoT has created hundreds of devices that connect to the internet and serve ads. Your TV, cell phone, game console, tablets, and maybe even your refrigerator are capable of serving ads. Eliminating ads on every device simultaneously requires blocking ads at a network level instead of individually on each device.
Pi-Hole works on the same principle as the uBlock Origin extension. Both compare your network activity to a blacklist full of thousands of black-listed advertisement domains. The key difference is that a Pi-Hole takes over as the DNS server for your entire network which enables it to block ad-serving traffic across the entire network.
Getting started with Pi-Hole is pretty simple.
I bought this kit from Amazon because it included the Raspberry Pi 3 B+ (although any Raspberry Pi should work), a power supply, case, heat sinks, and an SD card. You could save money by purchasing all the parts separately but I’m lazy.
You can do this on any computer with more than 50MB of space and 512MB of RAM but I chose a Raspberry Pi because it uses significantly less electricity than a full-scale desktop or server.
Raspbian is a lightweight Linux distribution that’s perfect for Pi-Hole. Detailed installation instructions are outside the scope of this article but it consists of three steps:
- Download the Raspbian image files
- Insert your SD card into your SD card reader
- Download Etcher and use it to burn the image to your SD card
Just run through the Raspbian setup process and move onto the next step once you have a functioning desktop environment.
The Pi-Hole Project hosts a super convenient bash script that will run an automated install process. Use curl to pull the script and pipe the output to bash.
Note: Piping to bash can be dangerous so ensure you trust the source of the script prior to executing any commands
curl -sSL https://install.pi-hole.net | bash
Once the script completes Pi-Hole is installed.
Be sure to remember the password that is displayed in the terminal after the bash script completes.
Before moving on, open a terminal and run
and record the IP address of your RaspberryPi for use in the next section.
Configuring DHCP clients to use Pi-hole for DNS
We need to ensure that any client that connects to our local network knows it should use the Pi-Hole for DNS requests. The easiest way to do this is by configuring the DHCP settings in your router.
You can usually determine the IP of your router by opening a Windows command line and running
and looking at the line labeled
Default Gateway . . . . . . . . . : 192.168.0.1
but this might not always be true (especially in complicated corporate networks). Nonetheless, figure out how to login to your router and look for a setting similar to DHCP settings.
Set your primary DNS field to the IP address of your RaspberryPi. I like to set the secondary DNS to a Google DNS server to ensure I don’t lose internet access in the event the Pi-Hole experiences a failure.
and log in with the admin password you wrote down earlier. You should be able to see statistics on your Pi-Hole if everything is working correctly.
My Pi-Hole has handled almost 9,000 DNS queries from 8 clients in just 24 hours. A staggering 10% (nearly 900) of those requests were identified as advertisement traffic and blocked by the Pi-Hole.
Congratulations! Your Pi-Hole is setup and blocking advertisements across every device on your network.