What is Pi-hole?
Pi-hole acts as your network's DNS server. When any device on your network tries to look up an ad-serving or tracking domain, Pi-hole intercepts that DNS request and returns nothing — the ad never loads. Unlike browser extensions, Pi-hole works on every device including smart TVs, phones, game consoles, and IoT devices.
✅ Works on any Linux machine — not just Raspberry Pi. Works great on Pi 4, Pi 5, Zero 2W, or any Ubuntu/Debian server.
Prerequisites
Step-by-Step Installation
Set a Static IP Address
Pi-hole needs a stable IP so your router can point DNS traffic at it reliably. Edit your DHCP settings or set a static IP on the Pi itself.
# Check your current IP
ip addr show
# For a static IP on Raspberry Pi OS, edit:
sudo nano /etc/dhcpcd.conf
# Add at the bottom (adjust to your network):
interface eth0
static ip_address=192.168.1.100/24
static routers=192.168.1.1
static domain_name_servers=127.0.0.1
Update Your System
Always start with a fresh, fully updated system.
sudo apt update && sudo apt full-upgrade -y
sudo reboot
Run the Pi-hole Installer
Pi-hole provides a one-line installer. It will walk you through a guided setup wizard.
curl -sSL https://install.pi-hole.net | bash
During setup: choose your upstream DNS provider (e.g. Cloudflare 1.1.1.1), confirm your static IP, and note down the web admin password shown at the end.
Access the Web Interface
Once installed, open a browser and navigate to the Pi-hole admin panel:
http://192.168.1.100/admin
# or
http://pi.hole/admin
Log in with the password shown during installation. You can change it with:
pihole -a -p
Point Your Router's DNS to Pi-hole
Log into your router admin panel and change the DNS server to your Pi's static IP. This makes every device on your network automatically use Pi-hole.
📍 Location varies by router: usually under LAN Settings → DHCP Server → DNS. Set Primary DNS to your Pi-hole IP (e.g. 192.168.1.100).
Add Blocklists
Pi-hole comes with the default blocklist, but you can add more for better coverage.
# Go to: Admin → Adlists
# Add lists like:
https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
https://adaway.org/hosts.txt
https://v.firebog.net/hosts/lists.php?type=tick
# Then update gravity (rebuild the blocklist database):
pihole -g
Verify It's Working
# Test a known ad domain (should return 0.0.0.0):
nslookup doubleclick.net 192.168.1.100
# Check Pi-hole status:
pihole status
# View live query log:
pihole -t
Useful Commands
| Task | Command |
|---|---|
| Update Pi-hole | pihole -up |
| Rebuild blocklist | pihole -g |
| Disable temporarily | pihole disable 10m |
| Re-enable | pihole enable |
| Live query log | pihole -t |
| Change password | pihole -a -p |
| Check version | pihole version |
| Whitelist domain | pihole -w example.com |
| Blacklist domain | pihole -b example.com |
Pair Pi-hole with Unbound
For maximum privacy, pair Pi-hole with Unbound as its upstream resolver. Instead of sending queries to Cloudflare or Google, Unbound resolves them directly from root servers — no third party ever sees your DNS traffic.
➡️ See the Unbound setup guide for integration instructions.