How to Install and Configure Pi-hole on Raspberry Pi
How to Install and Configure Pi-hole on Raspberry Pi Pi-hole is a network-wide DNS ad blocker. It runs on a Raspberry Pi and blocks ads, trackers, and malicious domains for every device on your network — no browser extension needed. Requirements Raspberry Pi (any model, Pi Zero 2W works great) Raspberry Pi OS Lite (headless recommended) Static IP configured (see guide: Set Up a Raspberry Pi Headless) A few minutes Step 1 — Give the Pi a Static IP Pi-hole needs a static IP so other devices always know where to send DNS requests. Option A — Set in your router DHCP reservations (easiest). Option B — Set in the Pi itself: bash sudo nano /etc/dhcpcd.conf Add at the bottom: interface eth0 static ipaddress=192.168.1.10/24 static routers=192.168.1.1 static domainnameservers=192.168.1.1 Save, then sudo reboot. Step 2 — Install Pi-hole bash curl -sSL https://install.pi-hole.net | bash The installer walks through a GUI in the terminal: Select your network interface (eth0 for wired, wlan0 for WiFi) Choose an upstream DNS provider (Cloudflare 1.1.1.1 is a good choice) Select blocklists (keep the default StevenBlack list) Enable the web admin interface Enable query logging Select log level (default is fine) Note the admin password at the end — or reset it with pihole -a -p newpassword. Step 3 — Point Your Network to Pi-hole In your router settings, change the Primary DNS to your Pi's static IP (e.g., 192.168.1.10). Leave Secondary DNS blank or set to 1.1.1.1 as fallback. Alternatively, configure individual devices to use the Pi as their DNS server. Step 4 — Access the Dashboard Open a browser and go to: http://192.168.1.10/admin Log in with your password. You'll see queries, blocked percentage, top domains, and more. Useful Commands bash Check Pi-hole status pihole status Update Pi-hole pihole -up Temporarily disable (10 minutes) pihole disable 10m Re-enable pihole enable Add domain to whitelist pihole -w example.com View live query log pihole -t Adding More Blocklists In the admin panel: Group Management → Adlists Good lists to add: https://raw.githubusercontent.com/hagezi/dns-blocklists/main/adblock/pro.txt — aggressive tracker blocking https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts — malware domains After adding lists: Tools → Update Gravity to rebuild the database. Tips Pi-hole blocks ~20-40% of DNS queries on a typical home network If a site breaks, check the query log and whitelist the domain Run Pi-hole on two Pis for redundancy — point secondary DNS to the second Pi
Related Guides
- Running Pi-hole on a Raspberry Pi Zero 2W
- Pi-hole Setup: Network-Wide Ad Blocking
- Running Your Own Recursive DNS Resolver on Raspberry Pi with Unbound: Full DNS Privacy Beyond Pi-hole
- Monitoring Your Home Network with Raspberry Pi and Grafana
- How to Install Klipper on Any 3D Printer: Complete Setup Guide
- How to Set Up OpenCV Machine Vision on a Raspberry Pi
- Raspberry Pi: Complete Headless Setup Guide (No Monitor Needed)
- Raspberry Pi: Headless OS Setup