Home Linux Block ads for every computer in your house with PiHole and Raspberry Pi

Block ads for every computer in your house with PiHole and Raspberry Pi

by Sean Ziegler

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 can serve ads. Eliminating ads on every device simultaneously requires blocking ads at a network level instead of individually on each device.

Meet Pi-Hole: A black hole for Internet advertisements

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 simple.

Raspberry Pi.
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 less electricity than a full-scale desktop or server.

Installing Raspbian

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.

Installing Pi-Hole

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

Pi-Hole is installed after the script is completed.

Be sure to remember the password displayed in the terminal after the bash script completes.

Before moving on, open a terminal and run


and record the IP address of your Raspberry Pi for 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 . . . . . . . . . :

but this might not always be true (especially in complicated corporate networks). Once you login to your router look for a setting called DHCP settings.

Edit the DNS fields under the DHCP settings in your router.

Set your primary DNS field to the IP address of your Raspberry Pi. 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.

Browse to


and log in with the admin password you recorded earlier. You should be able to see statistics on your Pi-Hole if everything works correctly.

The Pi-Hole Admin Interface

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 set up and blocking advertisements across every device on your network.

You may also like

Leave a comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept