Block Ads & Trackers with Pi-hole
Turn a Raspberry Pi into a network-wide ad blocker. Every device on your Wi-Fi gets ad-free, tracker-free DNS automatically.
What You'll Need
- Raspberry Pi (any model — even a Pi Zero W works) or any Linux machine / Docker host
- A microSD card (8GB+) and a way to flash it (SD card reader)
- Ethernet cable — Wi-Fi works but wired is more reliable for DNS
- Access to your router's admin page to change DNS settings
1 Flash Raspberry Pi OS
Download and install Raspberry Pi Imager — it handles everything for you.
- Download Raspberry Pi Imager for your OS
- Insert your microSD card
- Choose Raspberry Pi OS Lite (64-bit) — no desktop needed
- Click the ⚙️ gear icon to pre-configure:
- Set a hostname (e.g.
pihole) - Enable SSH (use password or key)
- Set username & password
- Configure Wi-Fi if no Ethernet
- Set a hostname (e.g.
- Click Write and wait
Eject the card, pop it in your Pi, plug in power + Ethernet, and give it a minute to boot.
pihole.local doesn't resolve, check your router's admin page for connected devices and find the Pi's IP address. Then ssh pi@192.168.x.x.
2 Install Pi-hole
One command. The installer walks you through everything.
The installer will ask a few questions:
- Upstream DNS — pick any (Cloudflare 1.1.1.1, Google 8.8.8.8, or Quad9 9.9.9.9)
- Blocklists — the default list is fine to start
- Web admin interface — yes, install it (this is the dashboard)
- Log queries — yes, so you can see what's being blocked
At the end, you'll see your admin password. Write it down.
curl -sSL https://install.pi-hole.net -o pihole-install.sh, inspect it, then bash pihole-install.sh.
Docker alternative:
3 Point Your Network to Pi-hole
This is the magic step — tell your router to use Pi-hole as the DNS server so every device on your network is protected automatically.
- Open your router's admin page (usually
192.168.1.1or192.168.0.1) - Find DHCP / DNS settings (often under LAN or Network)
- Set the Primary DNS to your Pi-hole's IP address
- Leave Secondary DNS blank (or set it to the same Pi-hole IP)
- Save and reboot the router
Test it:
4 Supercharge Your Blocklists
The default blocklist catches a lot, but adding community-curated lists takes it to the next level.
Go to Pi-hole Admin → Adlists and add these popular lists:
After adding lists, update gravity:
5 Keep Pi-hole Healthy
Pi-hole is pretty much set-and-forget, but a few things are worth knowing.
Common tasks from the dashboard:
- Whitelist a domain — if a site or app breaks, add it to the whitelist
- Disable temporarily — useful for debugging, click Disable → 5 minutes
- Query Log — see exactly what's being blocked and by which list
- Long-term data — graphs and stats over days/weeks
/etc/dhcpcd.conf:
interface eth0static ip_address=192.168.1.100/24static routers=192.168.1.1static domain_name_servers=1.1.1.1
✅ What You've Set Up
- Pi-hole running on your network — blocking ads and trackers at the DNS level
- Every device protected automatically — phones, tablets, smart TVs, IoT devices
- A web dashboard to monitor queries, manage blocklists, and whitelist domains
- Community blocklists for enhanced protection against ads, trackers, and malware
Next Steps
- Add Unbound — run your own recursive DNS resolver so you don't need Cloudflare or Google at all. Full privacy from ISP to browser.
- Pair with a VPN — use WireGuard so Pi-hole protects you even when you're away from home. See our Travel Router guide for a portable approach.
- Monitor with Grafana — connect Pi-hole's database to Grafana for detailed analytics and pretty dashboards.
- Set up redundancy — run a second Pi-hole on another device so DNS still works if one goes down.