Amazon Cyber Monday deals See deals →ad

Mets Minor League Blog

Music theory, instruments and musicians

Mets Minor League Blog

Music theory, instruments and musicians

Pi-hole on Raspberry Pi Zero: Setup Guide

Pi-hole is a network-wide ad blocker that runs on a Raspberry Pi and filters unwanted content for every device on your home network. By acting as your DNS server, it blocks ads, trackers, and malicious domains before they even reach your devices. The Raspberry Pi Zero is perfect for this because it’s tiny, cheap, and sips power—you can even hide it behind your router. This guide walks you through the entire setup, from flashing the OS to configuring your router, so you can enjoy a cleaner, faster, and more private internet experience.

What You’ll Need

  • Raspberry Pi Zero (any variant: Zero, Zero W, or Zero 2 W)
  • MicroSD card (8GB or larger, Class 10 recommended)
  • Micro USB power supply (5V/2A recommended)
  • USB OTG adapter (for Zero and Zero W) or a USB hub (for Zero 2 W) to connect a keyboard
  • HDMI cable and a monitor (for initial setup, unless you use SSH)
  • Another computer to write the SD card and access the Pi
  • Ethernet adapter (if using a Zero or Zero W, you’ll need a USB Ethernet adapter; the Zero 2 W has built-in Wi-Fi)
  • Internet connection and a router that lets you change DNS settings

Step-by-Step

  1. Download the Raspberry Pi OS image. Go to the official Raspberry Pi website and download the Raspberry Pi OS Lite image (32-bit is fine for the Zero). Lite is a headless version without a desktop, which saves resources.
  2. Flash the SD card. Use a tool like Raspberry Pi Imager (recommended) or balenaEtcher. Insert the SD card into your computer, open the imager, select the downloaded image, choose your SD card, and click Write. Wait for it to finish.
  3. Enable SSH (optional but recommended). After flashing, the SD card will appear as a drive called ‘boot’. Create an empty file named ssh (no extension) in the root of that drive. This allows you to connect via SSH later without a monitor.
  4. Configure Wi-Fi (if using Wi-Fi). If you’re using a Zero W or Zero 2 W and want Wi-Fi, create a file named wpa_supplicant.conf in the boot drive with the following content, replacing YOUR_SSID and YOUR_PASSWORD with your network details:
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    country=YOUR_COUNTRY_CODE
    
    network={
        ssid="YOUR_SSID"
        psk="YOUR_PASSWORD"
    }

    Replace YOUR_COUNTRY_CODE with your two-letter country code (e.g., US, GB, DE).

  5. Boot the Pi. Insert the SD card into the Pi, connect the Ethernet cable (if using wired) or rely on Wi-Fi, and plug in the power. Give it a minute to boot.
  6. Find the Pi’s IP address. If you have a monitor, you’ll see the IP on the login screen. If not, check your router’s admin page for connected devices, or use a network scanner like Angry IP Scanner. The default hostname is raspberrypi.
  7. SSH into the Pi. From your computer, open a terminal (or PuTTY on Windows) and run: ssh pi@<IP_ADDRESS>. The default password is raspberry. If you’re on a fresh install, you’ll be prompted to change it immediately.
  8. Update the system. Run sudo apt update and then sudo apt upgrade -y. This ensures you have the latest security patches.
  9. Install Pi-hole. Run the one-line installer: curl -sSL https://install.pi-hole.net | bash. Follow the on-screen prompts. Choose your upstream DNS provider (e.g., Google, Cloudflare, or OpenDNS). Accept the default blocklists. When asked about the web interface, choose to install it.
  10. Set a static IP address. After installation, you’ll be shown your Pi-hole’s IP address and the web interface URL. To ensure the Pi always has the same IP, set a static IP either on the Pi (via sudo nano /etc/dhcpcd.conf and adding lines like interface wlan0 or interface eth0, then static ip_address=192.168.1.100/24 and static routers=192.168.1.1) or better, via your router’s DHCP reservation.
  11. Set a password for the web interface. Run sudo pihole setpassword to set a password for the admin dashboard.
  12. Configure your router. Log into your router’s admin panel, find the DHCP or DNS settings, and set the DNS server to the Pi’s static IP address. This makes all devices on your network use Pi-hole automatically. If your router doesn’t allow custom DNS, you’ll need to set the DNS on each device manually.
  13. Test Pi-hole. Visit the Pi-hole web interface at http://<PI_IP>/admin, log in, and check the dashboard. You should see queries being logged. Try visiting a site with ads—they should be gone.

Common Mistakes

  • Not setting a static IP: If the Pi’s IP changes, your router’s DNS setting will break, and you’ll lose ad blocking.
  • Using the wrong Wi-Fi credentials: A typo in the wpa_supplicant.conf file will prevent the Pi from connecting. Double-check the SSID and password.
  • Forgetting to enable SSH: Without the ssh file, you can’t connect remotely, and you’ll need a monitor and keyboard.
  • Choosing the wrong SD card: A slow or small card can cause performance issues. Use at least 8GB Class 10.
  • Not updating the system first: Installing Pi-hole on an outdated OS can lead to dependency issues.

Tips

  • Use a wired connection: If possible, connect the Pi via Ethernet for more stable performance. The Zero W’s Wi-Fi is fine, but wired is better.
  • Back up your Pi-hole configuration: Regularly copy the /etc/pihole directory or use the web interface’s Teleporter feature to export settings.
  • Customize your blocklists: Add additional blocklists from reputable sources to block more threats, but be cautious not to over-block and break websites.
  • Monitor your logs: The Query Log in the web interface shows you what’s being blocked. Use it to whitelist any false positives.
  • Update Pi-hole regularly: Run pihole -up to update Pi-hole and its blocklists.

Troubleshooting

  • Pi won’t boot: Check the power supply (must be at least 2A), re-flash the SD card, and ensure the card is fully inserted.
  • Can’t SSH: Verify the Pi is on the network (check router), confirm SSH is enabled (the ssh file exists), and try pinging the IP.
  • No internet after setting DNS: If you set the router’s DNS to the Pi but the Pi’s DNS is not working, devices can’t resolve domains. Check that Pi-hole is running (sudo pihole status) and that the Pi’s own DNS is set correctly (it should be 127.0.0.1).
  • Web interface not loading: Ensure the lighttpd service is running (sudo service lighttpd status), and check that you’re using the correct IP and port (80).
  • Ads still showing: Some ads are served from the same domain as content. Try adding more blocklists, or check that your devices are actually using the Pi as DNS (you can see them in the Query Log).
  • Pi is slow: The Zero is not powerful; if you have many devices, consider using the Zero 2 W or a Pi 3/4. Also, disable unused features like the web interface if you don’t need it.

Frequently Asked Questions

Q: Can I use Pi-hole on a Raspberry Pi Zero without Wi-Fi?
A: Yes, the Zero and Zero W have no built-in Ethernet, but you can use a USB Ethernet adapter. The Zero 2 W has Wi-Fi built-in.

Q: Will Pi-hole slow down my internet?
A: No, it usually speeds it up because it blocks ads and trackers before they load, reducing data usage and page load times.

Q: Can I use Pi-hole with a VPN?
A: Yes, you can combine Pi-hole with a VPN like WireGuard or OpenVPN to block ads on the go. Pi-hole has built-in support for VPNs.

Q: How do I uninstall Pi-hole?
A: Run sudo pihole uninstall and follow the prompts. It will remove Pi-hole and restore previous DNS settings.

Q: Does Pi-hole work with IPv6?
A: Yes, Pi-hole supports IPv6. You need to set the IPv6 DNS address on your router as well.

Q: Can I use Pi-hole to block specific websites?
A: Yes, you can add domains to the blacklist in the web interface under ‘Blacklist’ to block them entirely.

Pi-hole on Raspberry Pi Zero: Setup Guide
Scroll to top