Pi-hole is a free DNS-based ad blocker that runs on a Raspberry Pi and filters ads and trackers for every device on your home network, including smart TVs, consoles and phones that can’t run a browser extension. Installing it takes about 30 minutes: flash Raspberry Pi OS to a card, run a one-line installer, point your router’s DNS at the Pi, and add a couple of blocklists. This guide walks through each step, the settings that stop it breaking things, and the cases where it isn’t worth the effort.
Key takeaways
- Any Raspberry Pi works, including the Zero 2 W. A Pi 4 or Pi 5 with 2 GB of RAM is comfortable and leaves room for other services.
- Pi-hole blocks at the DNS level, so it stops ads in apps and on smart TVs, but cannot remove YouTube in-video ads or ads served from the same domain as the content.
- Give the Pi a static IP before you point the router at it. If the Pi’s address changes, the whole house loses internet.
- Start with the default blocklist and add one or two curated lists. Piling on lists causes more breakage than blocking.
- The hardware costs a low two-figure sum for a Zero 2 W kit up to a high two-figure sum for a Pi 5 with case and power supply, at the time of writing.
What Pi-hole does and doesn’t do
Every time a device loads a website or an app phones home, it first asks a DNS server to turn a domain name into an IP address. Pi-hole becomes that DNS server for your network. When a device asks for an advertising or tracking domain on its blocklist, Pi-hole answers with nothing, so the ad never loads. Legitimate requests are passed upstream to a normal resolver.
That approach has clear limits. It cannot block ads that come from the same domain as the content (YouTube, Twitch, some news sites), it cannot change what’s inside a page, and it doesn’t affect devices that use their own hard-coded DNS or DNS-over-HTTPS unless you take extra steps. What it does well is remove the bulk of display ads and tracking from everything at once, speed up page loads slightly, and give you a dashboard showing which devices are chatty. The official Pi-hole documentation is thorough and worth bookmarking.
What you need
- A Raspberry Pi. Zero 2 W is enough for a home. Pi 4 or 5 if you want to add other services later.
- A microSD card, 16 GB or more, from a known brand. Cheap cards fail early and take Pi-hole down with them.
- The official power supply for your model. Undervoltage causes random crashes that look like software bugs.
- A case, ideally with some airflow.
- Optional but recommended: an Ethernet connection to your router. Wi-Fi works, but DNS over a flaky wireless link makes every page load feel slow.
- A computer with Raspberry Pi Imager installed, and admin access to your router.

Step by step
Step 1: Flash the card
- Open Raspberry Pi Imager. Choose your Pi model, then Raspberry Pi OS Lite (64-bit). Lite has no desktop, which Pi-hole doesn’t need.
- Click the settings gear before writing. Set a hostname such as pihole, enable SSH with a password, set a username and password, and enter your Wi-Fi details if you’re not using Ethernet.
- Write the card, put it in the Pi, connect Ethernet, and power on. Give it two minutes.
Step 2: Connect to the Pi
From a Mac or Linux terminal, or Windows PowerShell, connect with SSH using the username you set and the hostname pihole.local. If that name doesn’t resolve, find the Pi’s IP address in your router’s device list and use that instead. Once in, update the system with the usual apt update and apt full-upgrade commands, then reboot.
Step 3: Reserve a static IP
Do this now, not later. In your router’s DHCP settings, find the Pi by its MAC address and reserve its current IP. This keeps the address fixed without touching the Pi’s own network config, which is the least fragile method.
Step 4: Install Pi-hole
Run the one-line installer from the Pi-hole documentation. It uses curl to fetch the script and pipe it to bash. The installer asks a few questions: which interface (eth0 for Ethernet), which upstream DNS provider (Cloudflare or Quad9 are sensible defaults), whether to include the default blocklist (yes), and whether to install the web admin interface and query logging (yes to both). At the end it prints the admin password; write it down or set your own with the pihole setpassword command.
Step 5: Point the network at Pi-hole
Log in to your router and find the DHCP or LAN settings. Set the primary DNS server to the Pi’s IP address and leave the secondary blank. If the router insists on a secondary, enter the Pi’s address again. Entering a public resolver as the secondary lets devices bypass Pi-hole at random, which is a common reason people think it “only half works”. Then reconnect your devices to Wi-Fi so they pick up the new DNS. If your router won’t let you change the DNS it hands out (some ISP-supplied ones don’t), use Pi-hole’s built-in DHCP server and turn off the router’s.
Step 6: Check it’s working
Open the admin page at the Pi’s address followed by /admin. The dashboard should show queries arriving from your devices within a minute. Visit a few ad-heavy sites. The Query Log will show blocked domains in red.
Blocklists: less is more
The default list blocks around 100,000 domains and catches the majority of ads with very little breakage. If you want more coverage, add a curated collection rather than dozens of random lists; the Hagezi and OISD lists are well maintained and documented. After adding a list, run the gravity update from the Tools menu. If a site or app breaks afterwards, check the Query Log, find the domain being blocked, and whitelist it. Common early whitelist entries include the domains behind some banking apps, software licence checks and email tracking links you need to click.

Making it stick
Handle devices that ignore your DNS
Some smart TVs, streaming sticks and Chromecasts have Google’s DNS hard-coded. The fix is a router firewall rule that redirects all outbound port 53 traffic to the Pi, or blocks it except from the Pi. Many router firmwares expose this under NAT or firewall rules; on stock ISP routers it’s often missing, which is one reason people move to a more capable router. The VPN router guide lists models with proper firewall controls.
Add Unbound for private lookups
By default Pi-hole forwards unblocked queries to a public resolver. Installing Unbound on the same Pi turns it into a recursive resolver that asks the root servers directly, so no single company sees your whole browsing history. The Pi-hole docs have a copy-and-paste guide. It adds a slight delay on the first lookup of a domain, then caches.
Automate updates
Pi-hole updates itself with the pihole -up command. Schedule it monthly with cron along with the OS updates, and schedule a reboot afterward. Keep a backup of your settings using the Teleporter tool in the admin interface; it exports lists, whitelist and settings in one file so a dead SD card is a 20-minute recovery rather than an afternoon.
Use it away from home
Pi-hole only filters devices on your network. To take it with you, run a VPN server on the Pi or router (WireGuard is light enough for a Pi Zero) and connect your phone through it. The travel router guide covers doing the same from a hotel room.
Common problems and fixes
- Everything stops resolving. The Pi is off or its IP changed. Power-cycle it and check the DHCP reservation.
- Ads still show on one device. It’s using its own DNS, DNS-over-HTTPS in the browser, or a VPN. Check its network settings and disable secure DNS in the browser for your home network.
- A site won’t load. Find the blocked domain in the Query Log and whitelist it.
- Dashboard shows queries only from the router. Your router is proxying DNS. Set Pi-hole as the DHCP server so devices talk to it directly.
- Random reboots or corrupted card. Almost always the power supply or a cheap SD card.
Who this is not for
If you’re the only person in the house and you browse on one laptop, a browser extension like uBlock Origin does more, blocks YouTube ads, and needs no hardware. If your household relies on you being reachable and you’ll be travelling, a Pi-hole that goes down while you’re away takes the internet with it, unless you configure a fallback carefully. And if you’re on an ISP router with no DNS or firewall options and no appetite to replace it, half the network will bypass the Pi and you’ll wonder why it doesn’t work. Pi-hole is for households with many devices, smart TVs and phones full of ad-supported apps, and someone willing to spend an hour a year on maintenance. For those homes it’s one of the most satisfying projects a Pi can do. If you also want to keep your DNS traffic private on public networks, pair it with the advice in the VPN comparison.
Frequently asked questions
Does Pi-hole speed up my internet?
Pages load a little faster because ad and tracker requests never leave the house. Download speed is unchanged.
Does it block ads inside phone apps?
Many of them, yes, because app ads come from separate ad domains. Apps that serve ads from their own servers, and YouTube, are not affected.
Can I use Pi-hole when I’m away from home?
Only through a VPN back into your home network. On its own it filters the local network only.
Do I need a Raspberry Pi specifically?
No. Pi-hole runs on any Debian or Ubuntu machine, a Docker container on a NAS, or an old laptop. The Pi is popular because it’s small, silent and uses about two watts.
What if the Pi crashes or loses power?
DNS stops and devices lose internet until it’s back. Keep the Pi on a good power supply, take a Teleporter backup, and consider a second Pi-hole as a secondary DNS if uptime matters.
Is blocking ads legal?
Yes. You’re choosing which domains your own network resolves. Some sites may ask you to disable blocking to view content, which is their choice to make.
