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
- 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.
- 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.
- 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. - 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.confin the boot drive with the following content, replacingYOUR_SSIDandYOUR_PASSWORDwith 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_CODEwith your two-letter country code (e.g., US, GB, DE). - 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.
- 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. - SSH into the Pi. From your computer, open a terminal (or PuTTY on Windows) and run:
ssh pi@<IP_ADDRESS>. The default password israspberry. If you’re on a fresh install, you’ll be prompted to change it immediately. - Update the system. Run
sudo apt updateand thensudo apt upgrade -y. This ensures you have the latest security patches. - 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. - 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.confand adding lines likeinterface wlan0orinterface eth0, thenstatic ip_address=192.168.1.100/24andstatic routers=192.168.1.1) or better, via your router’s DHCP reservation. - Set a password for the web interface. Run
sudo pihole setpasswordto set a password for the admin dashboard. - 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.
- 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.conffile will prevent the Pi from connecting. Double-check the SSID and password. - Forgetting to enable SSH: Without the
sshfile, 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/piholedirectory 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 -upto 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
sshfile 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.