Pi-hole is a DNS sinkhole. It blocks unwanted content across your entire network without needing to install anything on individual devices. In practice, that means network-wide ad blocking. Phones, smart TVs, IoT junk, all of it gets filtered. No client-side setup needed.
One thing to be clear about: Pi-hole won’t block YouTube ads. Those come from the same domains as the videos themselves. For that, a browser extension like uBlock Origin is your best bet.
Prerequisites
- Raspberry Pi 3 or newer
- An SD card
- Access to your router’s DHCP settings (to change the DNS server)
- Some time
Prepare Pi for Install
Download the OS
Grab Raspberry Pi OS. The Lite version is fine for a headless setup.
Write the image to SD card
Unzip the download first. You’ll get an image file like 2021-05-07-raspios-buster-armhf-lite.img.
Do not flash the zip file directly.
GUI method (Linux/Windows)
Use the official Raspberry Pi Imager:
- Windows: Download here
- Linux (Debian/Ubuntu):
sudo apt update && sudo apt install rpi-imager
dd method (Linux)
sudo dd if=<Path to Image File> of=<Path to SD card> bs=4096 status=progress && sync
# e.g. sudo dd if=./2021-05-07-raspios-buster-armhf-lite.img of=/dev/sdb bs=4096 status=progress && sync
Boot and Update
Insert the SD card, plug in Ethernet, and power it on. It’ll resize the filesystem on first boot. You might need a monitor and keyboard if SSH isn’t enabled by default.
Login with the defaults (pi / raspberry) and update:
sudo apt-get update && sudo apt-get dist-upgrade
Reboot.
Install Pi-hole
Pi-hole has a one-line installer:
curl -sSL https://install.pi-hole.net | bash
The installer will spit out a web GUI password at the end. Save it. You’ll need it.
Configure Pi-hole
The web interface runs on port 80 under /admin. Find your Pi’s IP:
ip addr
Then visit:
http://172.17.1.252/admin
Log in with the password from the installer. The default blocklists catch roughly 90% of ads out of the box. Tweak whatever settings you want, then reboot the Pi one last time.
Configure Your Router’s DHCP
Pi-hole can act as a DHCP server, but using your router’s built-in DHCP is usually cleaner. Go into your router’s settings and change the DNS server address to your Pi’s IP.
This step varies wildly between router models. Check your router’s manual. Set the Pi’s IP as the primary DNS server.
Secondary DNS
Pi-hole recommends being your only DNS server, but if the Pi dies your whole network goes down. Add a secondary DNS as a failover. A few ads might slip through when the failover kicks in, but it’s rare.
Popular options:
- Google:
8.8.8.8,8.8.4.4 - Cloudflare:
1.1.1.1,1.0.0.1 - OpenDNS:
208.67.222.222,208.67.220.220
Let me know if I missed anything.