Raspberry Pi Zero Pi-hole: Setup Guide
In this article
Pi-hole is a network-wide ad blocker that runs on a Raspberry Pi Zero. Instead of blocking ads in a single browser, it filters DNS requests for your entire home network, so every device—phones, laptops, smart TVs, and tablets—gets ad and tracker blocking without installing anything on them. This guide walks you through flashing the OS, installing Pi-hole, and configuring your router to use it. You'll need a Raspberry Pi Zero (any variant), a microSD card (8GB or larger), a micro-USB power supply, and a computer with an SD card reader. A wired Ethernet connection via a USB-OTG adapter is strongly recommended for reliability, though you can use Wi-Fi if you configure it first.
What You'll Need
- Raspberry Pi Zero, Zero W, or Zero 2 W
- MicroSD card (8GB or larger, Class 10 recommended)
- Micro-USB power supply (5V, 2A recommended)
- Computer with SD card reader
- USB-OTG to Ethernet adapter (optional but recommended)
- HDMI cable and mini-HDMI adapter (only for initial setup troubleshooting)
- Router admin access (to change DNS settings)
Step-by-Step
- Download Raspberry Pi OS Lite. Go to the official Raspberry Pi website and download the Lite version (no desktop) of Raspberry Pi OS. It's smaller and uses fewer resources, which is ideal for a Pi Zero.
- Flash the SD card. Use Raspberry Pi Imager (or BalenaEtcher) to write the image to your microSD card. In Imager, select your device, choose the OS image, and pick your SD card. Before writing, click the gear icon to set hostname (e.g.,
pihole), enable SSH, and set a username and password. If you're using Wi-Fi on a Zero W, enter your Wi-Fi credentials in the same settings screen. - Boot the Pi. Insert the SD card into the Pi Zero, connect Ethernet (if using), and plug in power. Wait 1-2 minutes for it to boot.
- Find the Pi's IP address. On your computer, open your router's admin page (usually 192.168.1.1 or 192.168.0.1) and look at the DHCP client list. Find the device named
piholeor the hostname you set. Note its IP address, e.g., 192.168.1.50. - SSH into the Pi. From a terminal (macOS/Linux) or PowerShell (Windows), run:
ssh pihole@192.168.1.50(replace with your IP and username). Accept the fingerprint prompt and enter the password you set. - Update the system. Run
sudo apt update && sudo apt upgrade -y. This ensures packages are current before installing Pi-hole. - Install Pi-hole. Run the official installer:
curl -sSL https://install.pi-hole.net | bash. Follow the on-screen prompts: choose your upstream DNS provider (e.g., Cloudflare or Google), select a blocklist (the default is fine), and set a static IP address when asked—this is critical so the router can always find the Pi-hole. - Set a static IP. The installer will ask if you want to set a static IPv4 address. Choose Yes and enter the IP you noted earlier, plus your router's IP as the gateway and your preferred DNS (e.g., 1.1.1.1). If you skip this, do it later in
/etc/dhcpcd.conf. - Get the admin password. At the end of installation, Pi-hole shows a randomly generated admin password. Save it. To change it later, run
pihole -a -p. - Access the web interface. In a browser on your computer, go to
http://192.168.1.50/admin(use your Pi's IP). Log in with the password. You'll see the dashboard with query counts and block percentages. - Configure your router to use Pi-hole. Log into your router's admin page. Look for DHCP or LAN settings. Find the DNS server fields—replace the current DNS (often your ISP's) with your Pi's IP address (e.g., 192.168.1.50). Save and reboot the router if prompted.
- Test the setup. After the router reboots, restart a device (or renew its DHCP lease). Visit a site with heavy ads or trackers. You should see fewer ads. On the Pi-hole dashboard, you'll see queries being blocked in real-time.
Common Mistakes
- Skipping the static IP. If the Pi's IP changes via DHCP, your router points to a dead DNS server and internet breaks. Always set a static IP during install or immediately after.
- Using Wi-Fi on a Zero W without configuration. The Lite image doesn't auto-connect to Wi-Fi. You must enter credentials in Raspberry Pi Imager's settings before first boot.
- Forgetting to update the router's DNS. Installing Pi-hole doesn't do anything until your router points devices to it. You must change the router's DHCP DNS settings.
- Powering the Pi from a computer USB port. The Pi Zero can draw more than a standard port provides, causing random reboots or SD card corruption. Use a dedicated 5V/2A adapter.
- Blocking your own DNS. If you set the Pi's own DNS to itself, it can loop. Always set the Pi's upstream DNS to a public resolver like 1.1.1.1 or 8.8.8.8.
Tips
- Use a wired connection. Ethernet is more stable than Wi-Fi on a Pi Zero, especially for a network service. A USB-OTG adapter is cheap and worth it.
- Back up your SD card. After a successful install, shut down the Pi, remove the SD card, and make an image backup with Raspberry Pi Imager's 'Read' function. Restore it if the card fails.
- Whitelist false positives. If a site breaks (e.g., a login page won't load), check the Query Log in the admin UI, find the blocked domain, and add it to the whitelist.
- Update Pi-hole regularly. Run
pihole -upto update Pi-hole and its blocklists. Set a monthly reminder. - Monitor temperature. The Pi Zero runs cool, but if it's in a closed case, check
vcgencmd measure_tempoccasionally. It should stay under 60°C.
Troubleshooting
- No internet after router change. Revert the router DNS to automatic, then check the Pi-hole is reachable: from a computer, run
nslookup google.com 192.168.1.50. If it fails, SSH into the Pi and runpihole statusto check the service is running. - Pi-hole isn't blocking ads. Verify your device is using Pi-hole as DNS: on a phone, check Wi-Fi settings for the DNS server. If it shows your router's IP, the router didn't push the new DNS. Reboot the device or renew the DHCP lease.
- Pi won't boot (no SSH). Check the power LED. If it's off, the power supply is insufficient. If the LED is on but SSH times out, reflash the SD card with the Imager settings and try again. Test with an HDMI monitor to see boot errors.
- Web interface won't load. From the Pi, run
sudo systemctl status pihole-FTL. If it's inactive, runsudo systemctl start pihole-FTL. Also check that port 80 is open:sudo netstat -tulpn | grep :80. - DNS resolution is slow. Your upstream DNS might be slow. Change it in the Pi-hole admin under Settings → DNS, then pick a different provider. Also check that the Pi's network connection isn't dropping packets.
- Some devices bypass Pi-hole. Some routers allow devices to set their own DNS (e.g., via manual settings). You can block outbound DNS traffic on your router's firewall, but that's advanced. For now, manually set each device's DNS to the Pi's IP.
Frequently Asked Questions
- Does Pi-hole work with IPv6? Yes, but you must configure IPv6 DNS on your router as well. Most home networks use IPv4, so it's optional. Check your router's DHCPv6 settings to add the Pi's IPv6 address if needed.
- Will it slow down my internet? No. DNS lookups are tiny and Pi-hole caches them, so it often feels faster. The Pi Zero can handle hundreds of queries per second, far more than a typical home needs.
- Can I use Pi-hole with a VPN? Yes, but you need to configure the VPN client to route DNS through Pi-hole. For OpenVPN or WireGuard, set the DNS server in the client config to your Pi's IP. Otherwise, VPN traffic bypasses Pi-hole.
- How do I update the blocklists? Run
pihole -upto update Pi-hole and lists, orpihole -gto just update gravity (the blocklists). You can also schedule a weekly cron job. - Does it block YouTube ads? No. YouTube serves ads from the same domains as the video content, so blocking them would break playback. Pi-hole blocks most banner and tracker ads, but not in-stream video ads.
- Can I run Pi-hole with other software on the Pi? Yes, the Pi Zero has limited RAM (512MB), so avoid heavy services. Lightweight things like a simple web server or a temperature sensor script work fine. Run
htopto monitor memory usage.