How to Set Up Pi-hole on a Raspberry Pi (Beginner's Guide)
Block ads and trackers on every device in your house with Pi-hole on a Raspberry Pi. Complete setup guide with static IP, router DNS and troubleshooting.
Set up Pi-hole on a Raspberry Pi
From flashing Raspberry Pi OS to blocking ads network-wide, in about 45 minutes.
Estimated time: PT45M
Flash Raspberry Pi OS Lite
Use Raspberry Pi Imager to write Raspberry Pi OS Lite (64-bit) to a microSD card, pre-configuring the hostname, username, SSH and Wi-Fi in the settings dialog.
Boot and connect over SSH
Insert the card, power the Pi with Ethernet connected, find its IP address in your router's client list, and log in with ssh.
Update the system and give it a fixed IP
Run apt update and upgrade, then either reserve the Pi's IP in your router's DHCP settings (recommended) or configure a static IP with nmcli.
Install Pi-hole
Run the official installer with curl, answer the prompts, choose an upstream DNS provider and set an admin password.
Point your router at Pi-hole
In your router's DHCP/DNS settings, set the Pi as the primary DNS server, keeping your router or a public resolver as the secondary fallback.
Verify ad blocking works
Open the Pi-hole dashboard, check that queries are flowing, and test ad blocking on any device in the house.
Every device in your house asks the internet “where is this website?” dozens of times a minute. Right now, your router answers that question by forwarding it to your internet provider — including for every ad, tracker and analytics script embedded in the page you’re reading.
Pi-hole puts a tiny DNS server in your house that answers those questions itself. When a device asks for a known advertising domain, Pi-hole says “no such address” — and the ad simply never loads. Not in the browser, not in most mobile apps, not on your smart TV. One Raspberry Pi, one setup, every device covered.
Here’s the honest scope: Pi-hole blocks the infrastructure of web tracking extremely well. It does not block YouTube ads (they come from the same servers as the videos), and it can’t see inside anything that uses encrypted DNS of its own. What it does, it does better than almost anything else — and it runs on hardware drawing just 3–5 watts of power (less than $10 a year in electricity).
What you need
- A Raspberry Pi — 3B+, 4 or 5, any RAM size. (A Pi Zero 2 W technically works, but you’ll want Ethernet.)
- A microSD card, 16 GB or larger, class A2 recommended
- The official power supply — cheap phone chargers cause random undervoltage reboots and SD corruption
- An Ethernet cable to your router
- About 45 minutes
Step 1: Flash Raspberry Pi OS Lite
Download Raspberry Pi Imager and choose Raspberry Pi OS Lite (64-bit). Lite means no desktop — perfect for a headless DNS server.
Before writing, open OS Customisation (the gear icon / Edit Settings) and set:
- Hostname:
pihole(or any name you like) - Username and password (write them down)
- Enable SSH with password authentication (or paste your public SSH key)
- Wi-Fi details only if you can’t use Ethernet — Ethernet is strongly preferred
Flash the microSD card, insert it into the Pi, connect the Ethernet cable, and plug in power.
Step 2: Find the Pi and log in
After a minute or two, find the Pi’s IP address in your router’s admin page (usually under “connected devices” or “DHCP leases”, looking for pihole). Then from your computer:
ssh yourusername@pihole.local# or, if .local doesn't resolve on your network:ssh yourusername@192.168.1.123First order of business — update packages:
sudo apt update && sudo apt full-upgrade -yStep 3: Give the Pi a fixed IP address
Pi-hole’s address must not change, or your whole network stops resolving domains when DHCP hands it a different lease. Two ways, in order of preference:
Option A — DHCP reservation (recommended). In your router’s admin page, find the Pi in the client list and reserve its current IP permanently. Every router words this differently (“static lease”, “reserve IP”, “bind”), but the concept is identical, and it keeps IP management in one place.
Option B — static IP on the Pi itself (Raspberry Pi OS Bookworm and later use NetworkManager):
# See the connection name — usually "Wired connection 1"nmcli con show
# Replace the values with YOUR network's — use our subnet calculator if unsuresudo nmcli con mod "Wired connection 1" \ ipv4.method manual \ ipv4.addresses 192.168.1.10/24 \ ipv4.gateway 192.168.1.1 \ ipv4.dns "1.1.1.1"
sudo nmcli con up "Wired connection 1"Warning
Use an address OUTSIDE your router’s DHCP pool (check our subnet calculator if you need to see the exact usable range), or the router may hand the same IP to another device. If your pool is192.168.1.100–192.168.1.250, an address like .10 is safe. When in doubt, use Option A.Step 4: Install Pi-hole
The official one-line installer is the supported path:
curl -sSL https://install.pi-hole.net | bashWalk through the prompts:
- Upstream DNS provider: Cloudflare (
1.1.1.1) or Quad9 (9.9.9.9) are both solid. This is who Pi-hole asks when a domain isn’t blocked. - Blocklists: accept the default list (StevenBlack’s unified hosts).
- Web interface: yes (you’ll manage everything from this dashboard).
- Query logging: keep it on — it’s how you debug blocked sites.
- Admin password: set a strong one (or reset it afterwards with
sudo pihole setpassword).
When it finishes, note the URL and password it prints. Open it from any device:
http://192.168.1.10/adminLog in and you’ll immediately see the four summary cards at the top: Total Queries, Queries Blocked, Percentage Blocked, and Domains on Adlists.
Step 5: Point your network at Pi-hole
This is the step that makes everything click: tell your router to hand out the Pi’s IP as the primary DNS server to every device.
- Log into your router’s admin page (usually
192.168.1.1). - Find DHCP settings (sometimes “LAN settings” or “DNS server”).
- Set Primary DNS to your Pi’s IP (e.g.
192.168.1.10). - Secondary DNS trade-off: if you leave Secondary DNS empty (or point it at the same Pi), 100% of queries go through Pi-hole, but internet browsing stops if you unplug the Pi. Setting a fallback like
1.1.1.1keeps the household online during maintenance, though some devices (especially Android phones) will occasionally send 10–20% of queries straight to the secondary server even when the Pi is up. For a family network where you don’t want complaints if you reboot the Pi, keeping a fallback — or better yet, eventually running a second Pi-hole — is the pragmatic choice.
Devices only pick up the change when they renew their DHCP lease or reconnect. Reboot your phone and laptop, or toggle Wi-Fi off and on, to test quickly.
Step 6: Verify it works
- Open the dashboard — you should see queries flowing in immediately.
- On a phone or laptop, visit a news site and refresh a couple of times.
- The dashboard’s “Queries Blocked” card should start climbing; on a typical home network with laptops, phones and smart TVs, Pi-hole usually blocks 15% to 30% of all DNS lookups — and smart TVs are often the noisiest devices in the house, phoning home every few seconds even in standby.
- For a quick visual sanity check, visit
canyoublockit.comfrom any device.
Keep the blocklist and Pi-hole itself updated periodically:
pihole -g # update gravity (the blocklists)pihole -up # update Pi-hole itselfWhen blocking breaks something
The most common issue: you click a link (often a sponsored Google Shopping result or an email tracking link) and the page refuses to load because a legitimate service shares a domain with a tracker. The fix takes 10 seconds with an allowlist entry:
- In the Pi-hole dashboard, open Query Log and filter or locate the red Blocked query from your device.
- Click the Whitelist / Allow button right next to that domain, and it is unblocked network-wide immediately.
Advanced (for later)
- Unbound: run your own recursive DNS resolver under Pi-hole so no upstream provider (not even Cloudflare or Google) sees your lookups at all.
- Local DNS records: under Local DNS → DNS Records, point names like
jellyfin.home.arpato your server’s IP and pair it with a reverse proxy — covered in our Local DNS & Nginx Proxy Manager guide. - Tailscale + Pi-hole: set your Pi’s Tailscale IP as a global nameserver in Tailscale’s DNS tab so your phone gets ad-blocking even on 5G, without opening port 53 to the internet.
Troubleshooting
- Port 53 already in use — usually
systemd-resolved’s stub listener on Ubuntu. It’s normally handled by the installer; if not, edit/etc/systemd/resolved.conf, setDNSStubListener=no, and restartsystemd-resolved. - Ads still appear on one phone or browser — check if Android’s Private DNS or your browser’s DNS-over-HTTPS (DoH) is enabled. Both bypass your router’s DHCP DNS; set Private DNS to Off/Automatic on your home network if you want Pi-hole to filter that device.
- Everything’s slow or flaky — is the Pi on Wi-Fi? Move it to Ethernet before anything else. DNS is on the critical path for every single website and app on your network.
Where to go from here
- Pair it with Jellyfin on an old laptop for a complete low-power media + network setup
- Add safe remote access with Tailscale (no open ports, ever)
- Keep files in sync with Nextcloud
Once you see the Query Log after 24 hours — especially the sheer volume of telemetry domains your smart TVs and appliances try to contact overnight — Pi-hole becomes one of those homelab services you never want to live without.
Frequently Asked Questions
Does Pi-hole block YouTube ads?
No — and any guide claiming otherwise is outdated. YouTube serves ads from the same servers as the videos, so DNS blocking can't separate them. Pi-hole blocks a huge amount of the rest of the web's advertising and tracking, plus many in-app ads, but YouTube and Twitch ads still get through.
Does Pi-hole slow down my internet?
The opposite, usually. Pi-hole caches DNS answers, so repeat lookups are faster than with your router doing the work. Page loads even feel snappier because blocked ad and tracker requests fail immediately instead of loading.
Which Raspberry Pi do I need?
Anything modern works: a Pi 3B+, 4 or 5 with at least 1 GB of RAM runs Pi-hole comfortably for a typical home. The Pi 4 and 5 have more headroom if you also want to run other services. Always use a wired Ethernet connection — every device's DNS flows through this machine, so reliability matters.
What happens to my internet when the Pi-hole is off?
If the Pi is the only DNS server your router hands out, internet name resolution stops when it stops — pages won't load even though the connection is up. That's why the setup below recommends configuring a second DNS server as fallback on your router, and keeping the Pi wired over Ethernet on a dedicated power supply.
Should I set Pi-hole as DHCP server instead of my router?
It's an option, and it gives you per-device visibility in the Pi-hole dashboard, but it's an advanced step. Start by changing only the DNS setting in your router's DHCP configuration — it achieves 95 percent of the benefit with 5 percent of the risk.