Pi-hole is a network-wide ad blocker that runs on a Raspberry Pi and filters out ads and trackers for every device on your home network. Using a Raspberry Pi Zero (especially the Zero 2 W) keeps the cost low and the power draw tiny. This guide walks you through installing Pi-hole on a Pi Zero, configuring your router to use it, and verifying that it works.
What You’ll Need
- A Raspberry Pi Zero (original or Zero 2 W) with a microSD card (8GB or larger, Class 10 recommended)
- A micro-USB power supply (5V, at least 1A for the Zero; 2A for the Zero 2 W)
- A USB-OTG adapter and a USB Ethernet adapter (or a USB Wi-Fi dongle) to get network connectivity during setup – the Pi Zero has no built-in Ethernet
- An HDMI cable and a mini-HDMI adapter (if you want to see the console during first boot)
- A computer to write the SD card and to access the Pi’s web interface
- Raspberry Pi OS Lite (32-bit) – the minimal version is perfect for Pi-hole
- BalenaEtcher or similar SD card writing tool
- An SSH client (e.g., PuTTY on Windows, or terminal on macOS/Linux)
Step-by-Step
- Download Raspberry Pi OS Lite from the official Raspberry Pi website. Choose the 32-bit Lite image (no desktop) to keep resources low.
- Write the image to the microSD card using BalenaEtcher or your preferred tool. Wait for the write to finish and then eject the card.
- Enable SSH and configure Wi-Fi (optional) before first boot – after writing the image, the SD card will appear as a boot drive on your computer. Create an empty file named
ssh(no extension) in the root of the boot partition to enable SSH. If you want to use Wi-Fi instead of Ethernet, create a file namedwpa_supplicant.confwith the following content (replace SSID and password):ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=YOUR_COUNTRY_CODE
network={
ssid="YOUR_WIFI_SSID"
psk="YOUR_WIFI_PASSWORD"
} - Connect the Pi Zero to your network – if using Ethernet, plug in the USB Ethernet adapter. If using Wi-Fi, the Pi will connect automatically after boot.
- Power up the Pi – connect the micro-USB power cable. Wait about a minute for it to boot.
- Find the Pi’s IP address – check your router’s DHCP client list, or use a network scanner like
nmapor the Fing app. The hostname is usuallyraspberrypi. - SSH into the Pi – from your computer, run
ssh pi@<IP_ADDRESS>. The default password israspberry(change it later). - Update the system – run
sudo apt updateand thensudo apt upgrade -y. This ensures you have the latest packages. - Install Pi-hole – run the official installer:
curl -sSL https://install.pi-hole.net | bash. Follow the on-screen prompts. Choose a static IP address when asked (recommended) and select a DNS upstream provider (e.g., Cloudflare or Google). - Set a static IP address (if not done during install) – you can edit
/etc/dhcpcd.confand add lines like:interface wlan0(or eth0)static ip_address=192.168.1.100/24static routers=192.168.1.1static domain_name_servers=127.0.0.1
Then reboot withsudo reboot. - Access the Pi-hole web interface – open a browser and go to
http://<PI_IP>/admin. Log in with the password printed at the end of the install (or set one withpihole -a -p). - Configure your router to use Pi-hole as DNS – log into your router’s admin panel, find the DHCP settings, and set the DNS server to the Pi’s IP address. This makes every device on the network use Pi-hole automatically.
- Verify that Pi-hole is working – on any device, visit a site with ads (or run
nslookup doubleclick.netfrom a computer). The query should return 0.0.0.0 or be blocked. In the Pi-hole dashboard, you should see queries being logged.
Common Mistakes
- Not enabling SSH before first boot – you’ll have to plug in a monitor and keyboard to fix it.
- Using a Wi-Fi dongle that isn’t compatible with the Pi Zero – check the Raspberry Pi forums for known working models.
- Forgetting to set a static IP – if the IP changes, devices lose DNS and Pi-hole becomes unreachable.
- Not updating the system before installing Pi-hole – older packages can cause install failures.
- Setting the router’s DNS to the Pi’s IP but not disabling the router’s own DNS cache – some routers ignore this and still use their own DNS.
Tips
- Use a Pi Zero 2 W if possible – it’s faster and has Wi-Fi built-in, saving you from needing a USB Ethernet adapter.
- Place the Pi near your router for a stable wired connection if using Ethernet.
- Back up your Pi-hole configuration regularly – you can use
pihole -a -eto export settings. - Update Pi-hole regularly with
pihole -upto get new blocklists and bug fixes. - Consider adding extra blocklists from the Pi-hole community to improve coverage.
Troubleshooting
- Pi-hole isn’t blocking ads – Check that your router’s DNS is set correctly. Also, some devices (like phones) may have hardcoded DNS – you may need to set DNS manually on those devices.
- Can’t SSH into the Pi – Ensure the
sshfile is present on the boot partition. If you’re using Wi-Fi, double-check the wpa_supplicant.conf file for typos. Try connecting via Ethernet instead. - Pi-hole web interface won’t load – Verify the Pi is on the network and that you’re using the correct IP. Check that the lighttpd service is running with
sudo systemctl status lighttpd. - DNS queries are slow – This can happen if the Pi Zero is underpowered. Use a quality power supply and consider using a faster upstream DNS.
- Pi keeps losing network connection – This is often a power issue. Try a different power cable or a powered USB hub.
Frequently Asked Questions
Q: Can I use a Raspberry Pi Zero (original) for Pi-hole?
A: Yes, but it’s slower. The original Zero has a single-core CPU and 512MB RAM, which is enough for basic Pi-hole use, but the Zero 2 W is significantly faster and more responsive.
Q: Do I need a separate DNS server?
A: No, Pi-hole acts as a DNS server itself. It forwards queries to upstream DNS providers (like Google or Cloudflare) after filtering.
Q: Will Pi-hole block ads on my phone?
A: Yes, as long as your phone uses your router’s DNS (which it does by default when on Wi-Fi). Some apps use their own DNS, but most ads will be blocked.
Q: How do I change the Pi-hole admin password?
A: Run pihole -a -p from the terminal and follow the prompts.
Q: Can I use Pi-hole with a VPN?
A: Yes, you can set up a VPN on the Pi and route all traffic through it, but that’s a more advanced setup. Pi-hole itself only handles DNS.
Q: Will Pi-hole slow down my internet?
A: No, DNS queries are lightweight. The Pi Zero can handle hundreds of queries per second, so you won’t notice any slowdown.