Pi-hole is a network-wide ad blocker that runs on a Raspberry Pi. It acts as a DNS sinkhole, intercepting DNS requests from every device on your network and blocking known advertising and tracking domains before they load. The result: faster page loads, reduced bandwidth usage, and a cleaner browsing experience on all devices—phones, tablets, computers, even smart TVs. This guide walks you through the entire setup, from flashing the OS to configuring your router, and includes troubleshooting for common pitfalls.
What You’ll Need
- A Raspberry Pi (any model from the Pi 2 onward; Pi Zero W works but is slower)
- A microSD card (8 GB or larger, Class 10 recommended)
- A power supply (official Raspberry Pi power adapter recommended)
- An Ethernet cable (recommended for stability) or reliable Wi-Fi
- A computer with an SD card reader to flash the OS
- Software: Raspberry Pi Imager (free from raspberrypi.com) and an SSH client (like PuTTY for Windows, or Terminal on Mac/Linux)
Step-by-Step
- Flash Raspberry Pi OS (Lite) to the SD card. Download and install Raspberry Pi Imager on your computer. Insert the microSD card, open Imager, choose “Raspberry Pi OS (Lite)” (32-bit or 64-bit, either works), select your SD card, and click “Write.” Wait for the process to finish.
- Enable SSH before first boot. After flashing, the SD card will appear as a drive named “boot.” Create an empty file named
ssh(no extension) in the root of that drive. On Windows, use Notepad to create a file namedsshand remove the .txt extension. On Mac/Linux, usetouch /Volumes/boot/ssh. - Boot the Pi and find its IP address. Insert the SD card into the Pi, connect the Ethernet cable (or configure Wi-Fi by adding a
wpa_supplicant.conffile to the boot drive—instructions vary by OS version), and power it on. On your router’s admin page, look at the DHCP client list to find the Pi’s IP address (something like 192.168.1.100). - SSH into the Pi. Open your SSH client and connect to the Pi’s IP address. The default username is
piand the default password israspberry. On first login, you’ll be prompted to change the password—do so. - Update the system. Run
sudo apt updateand thensudo apt upgrade -y. This ensures you have the latest packages and security patches. - Run the Pi-hole installer. Execute the command:
curl -sSL https://install.pi-hole.net | bash. This downloads and runs the official installer script. Follow the on-screen prompts: choose your upstream DNS provider (Google, Cloudflare, etc.), accept the default blocklists, and set a static IP address when asked (recommended). The installer will set a random web admin password—note it down or change it later. - Access the admin console. After installation, open a web browser on any device and go to
http://<Pi's IP address>/admin. Log in with the password you set. You’ll see the dashboard with query statistics and a search bar. - Configure your router to use Pi-hole as DNS. Log into your router’s admin panel (usually at 192.168.1.1 or 192.168.0.1). Find the DHCP settings (often under “LAN” or “Network”). Set the DNS server to the Pi’s IP address. Save the settings and reboot the router or renew the DHCP lease on your devices. Now all devices will use Pi-hole for DNS.
- Test the setup. On a device, visit a website that shows ads (like a news site). You should see fewer or no ads. In the Pi-hole admin, go to “Query Log” to see blocked domains in real time.
- Set a static IP (if not done during install). If you skipped the static IP step, assign a static IP to the Pi via your router’s DHCP reservation (using the Pi’s MAC address) or by editing
/etc/dhcpcd.confon the Pi. This prevents the Pi’s IP from changing, which would break DNS.
Common Mistakes
- Forgetting to enable SSH—you can’t connect to the Pi without it.
- Using the wrong IP for DNS—make sure you enter the Pi’s IP, not your router’s IP.
- Not setting a static IP—if the Pi’s IP changes, DNS breaks.
- Blocking your own DNS—if you set the router’s DNS to the Pi, but the Pi uses the router as its upstream, you create a loop. Ensure the Pi’s upstream DNS is an external server (like 8.8.8.8).
- Forgetting to renew DHCP leases—devices may keep old DNS settings until they renew.
Tips
- Use the Pi-hole admin’s “Whitelist” feature to unblock domains that are incorrectly blocked (e.g., some legitimate sites use ad networks).
- Update Pi-hole regularly:
pihole -upupdates the software, andpihole -gupdates the blocklists. - Consider using a VPN (like WireGuard) to use Pi-hole when away from home.
- Back up your Pi-hole configuration via the admin console’s “Teleporter” feature.
- For better performance, use a wired Ethernet connection instead of Wi-Fi.
Troubleshooting
- Can’t SSH into the Pi: Verify the Pi is on the same network, check the IP address (try scanning with
nmap -sn 192.168.1.0/24), and ensure thesshfile is present on the boot drive. - Pi-hole admin not loading: Check that the Pi is running (
ping <IP>), and that the web server is active (sudo systemctl status lighttpd). Try accessinghttp://<IP>/adminfrom a different browser or device. - Ads still showing: Confirm that devices are using the Pi as DNS (on a device, check DNS settings or use
nslookup). Also, some ads are served from the same domain as content—these can’t be blocked without breaking the site. Clear your browser cache. - Internet is down after setting router DNS: This usually means the Pi is not reachable or is misconfigured. Temporarily revert the router DNS to automatic, then check the Pi’s DNS settings (
cat /etc/resolv.conf). Ensure the Pi has internet access (ping google.com). - Pi-hole is slow: If the Pi is older (like Pi 2), it may struggle with many queries. Consider using a lightweight upstream DNS like Cloudflare (1.1.1.1) and disable unnecessary services.
Frequently Asked Questions
Q: Will Pi-hole slow down my internet?
No, it typically speeds it up by blocking ads before they load. DNS queries are cached, and the Pi handles them quickly.
Q: Can I use Pi-hole with a VPN?
Yes, you can configure Pi-hole as the DNS server for your VPN clients, giving you ad-blocking on the go.
Q: Does Pi-hole work with IPv6?
Yes, but you need to configure IPv6 DNS settings on your router and ensure the Pi has an IPv6 address. The installer sets this up automatically if available.
Q: How do I unblock a site that’s being blocked?
In the admin console, go to “Whitelist” and add the domain. You can also disable Pi-hole temporarily via the “Disable” button.
Q: Can I run Pi-hole on other hardware?
Yes, Pi-hole can run on any Linux machine, Docker container, or even a virtual machine. The setup is similar.
Q: What happens if the Pi goes offline?
If the Pi is your only DNS server, internet access may break. To avoid this, set a secondary DNS on your router (like 8.8.8.8) as a fallback.