Pi-hole blocks ads for every device on your home network, from the TV to the phone, without installing anything on each device. To install Pi-hole on a Raspberry Pi you need the Pi itself, a microSD card, and about half an hour. This guide walks through the install, the DNS settings, and the blocklists, plus the recovery steps for the day something stops working.
Pi-hole is free and open source. It works as a DNS server: when a device asks for the address of an ad server, Pi-hole answers with a blank address instead, so the ad never loads. It does not block ads inside apps that serve them from their own servers, and it does not replace a browser ad blocker for everything, but for network-wide blocking it is the simplest tool that works.
What Pi-hole does at the network level
Every device on your network asks a DNS server to turn names like example.com into IP addresses. Pi-hole sits in that path. It checks each request against a list of known ad and tracking domains, and returns a blank answer for the ones on the list. Normal requests pass through to a real DNS server upstream. The result is fewer ads on every device, plus a dashboard that shows which domains your devices ask for most.
Because Pi-hole works at the DNS level, it protects devices that cannot run an ad blocker: smart TVs, game consoles, and phones on your Wi-Fi. That is the point of network-wide blocking. It is not a VPN and not a firewall; it only filters DNS. For the network side of a home server, our guide on setting up the UFW firewall on Ubuntu covers the firewall layer, and the roundup of the best used enterprise switches for a homelab network helps if your network grows past one switch.
What you need
- A Raspberry Pi 3, 4, or 5, with a power supply. A Pi 4 with 2 GB of RAM is plenty for Pi-hole.
- A microSD card, 16 GB or larger, for the operating system.
- An Ethernet cable. Pi-hole works over Wi-Fi, but a cable is steadier for a DNS server the whole house depends on.
- A computer to write the OS image to the card and to open the Pi-hole dashboard.
- Raspberry Pi OS Lite, the version without a desktop.
Step 1: Prepare the Pi
Write Raspberry Pi OS Lite to the microSD card with the Raspberry Pi Imager. In the Imager settings, set a hostname like pihole, enable SSH, and set a username and password. Then put the card in the Pi, connect the Ethernet cable, and power it on. Find the Pi’s IP address from your router’s device list, and connect over SSH.
Update the system first with sudo apt update and sudo apt upgrade. Then give the Pi a static IP address, or set a DHCP reservation in your router so the address never changes. A DNS server that moves is a DNS server that breaks the whole network, so do this before you install anything else.
Step 2: Install Pi-hole on a Raspberry Pi
Pi-hole ships with a one-command installer. From the official Pi-hole site, the command is curl -sSL https://install.pi-hole.net | bash, run as a normal user, not as root. The installer asks a short list of questions: which upstream DNS provider to use, which blocklists to enable, and whether to install the web dashboard. The defaults are sensible for a first install: pick Cloudflare or Google as the upstream DNS, enable the default blocklists, and install the web interface.
When the installer finishes, it prints the admin password for the web dashboard and the address to open it. Save that password somewhere safe. Log in to the dashboard and confirm the status shows active, with queries appearing as your devices start using the Pi.
Step 3: Point your network at Pi-hole
Pi-hole only works if your devices actually use it for DNS. The clean way is to change the DNS setting in your router’s DHCP options to the Pi’s IP address, so every device on the network picks it up automatically. The setting is usually under LAN or DHCP settings, and it may be called DNS server or primary DNS. Save it, then restart your devices or wait for their DHCP lease to renew.
If your router will not let you change the DNS server, the fallback is to turn off DHCP on the router and enable the DHCP server built into Pi-hole. That makes Pi-hole hand out addresses and its own DNS at the same time. It works well, but only change one thing at a time: a network with two DHCP servers gives out conflicting addresses, so make sure the router’s DHCP is off first.
Step 4: Blocklists and whitelists
The default blocklists cover the common ad networks. You can add more from the dashboard under Adlists, but add them one at a time and test for a day. Aggressive lists block things you actually use: shopping sites, app updates, and smart home services. When something stops working, check the Pi-hole query log for the blocked domain, and add it to the whitelist. The query log is the fastest way to find out what broke.
Keep the lists short at first. A Pi-hole with a hundred thousand blocked domains and a broken smart TV is worse than a Pi-hole with a modest list that nobody notices. The goal is ads gone and nothing else changed.
What to do when the internet breaks
Sooner or later, something will stop loading and Pi-hole will be the suspect. The fastest check is to change one device back to a public DNS server, such as 1.1.1.1, and see if the problem goes away. If it does, the cause is a blocked domain: find it in the query log and whitelist it. If the problem stays, the cause is elsewhere, and Pi-hole is innocent.
For the whole house, keep a fallback ready before you need it: a second DNS server in the router settings, or a note on the fridge with the steps to point the router back at the old DNS. A DNS server is a single point of failure for the network, so the recovery path matters as much as the install. Our notes on reverse DNS records for a VPS explain the DNS concepts behind the setup, and the comparison of Cloudflare Tunnel vs Nginx Proxy Manager vs Traefik covers the remote-access options if you later want to reach home services from outside.
To install Pi-hole on a Raspberry Pi well, the work is mostly before and after the installer: a static IP before, and a tested fallback after. The pi-hole raspberry pi setup takes an evening, the pi-hole network-wide ad blocking it gives you covers every device in the house, and a pi-hole dns ad blocker costs nothing beyond the Pi itself. Start with the default lists, whitelist what breaks, and check the dashboard after a week. The number of blocked queries will tell you how much noise was on your network all along.