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 before they even load. Instead of installing an ad blocker on each phone, laptop, or tablet, you set up Pi-hole once, and it protects everything connected to your router. This guide walks you through the entire process—from flashing the operating system to configuring your router—so you can enjoy a faster, cleaner internet experience.
What You’ll Need
- A Raspberry Pi (any model from the Raspberry Pi 2 onward; Pi 4 or 5 recommended for better performance)
- A microSD card (8 GB or larger, Class 10 recommended)
- A power supply for your Pi (official one recommended)
- An Ethernet cable (recommended for stable connection)
- A computer with an SD card reader to flash the OS
- Optional: a monitor and keyboard for initial setup (or use SSH)
Step-by-Step
- Flash Raspberry Pi OS onto the SD card. Download the Raspberry Pi Imager from the official Raspberry Pi website and install it on your computer. Insert the microSD card, open the Imager, choose your Pi model, select “Raspberry Pi OS (32-bit)” (or 64-bit if you prefer), and then choose your SD card. Click “Write” and wait for it to finish. Optionally, click the gear icon to enable SSH and set a username/password before writing.
- Boot your Raspberry Pi. Insert the SD card into the Pi, connect the Ethernet cable to your router, and plug in the power. If you set up SSH earlier, you can skip the monitor and keyboard. Otherwise, connect a monitor and keyboard to log in.
- Find your Pi’s IP address. If you have SSH enabled, you can find the IP from your router’s admin page (look for connected devices) or use a network scanner app. If you’re using a monitor, type
hostname -Iin the terminal to see the IP address. - Log in to your Pi. From your computer, open a terminal (or PuTTY on Windows) and run
ssh pi@your_pi_ip(replace with your username and IP). Enter the password you set earlier. If you didn’t set a password, the default israspberry. - Update your system. Run the following commands to update the package list and upgrade all packages:
sudo apt update sudo apt upgrade -yThis ensures you have the latest security patches and dependencies.
- Install Pi-hole. Run the official installation script:
curl -sSL https://install.pi-hole.net | bashFollow the on-screen prompts. Choose your upstream DNS provider (e.g., Google, Cloudflare, or your ISP’s), select a blocklist (the default is fine), and set a static IP address when asked (choose “Yes” to use DHCP reservation or set it manually later). The installer will display a web admin password—write it down or change it later.
- Access the Pi-hole admin dashboard. Open a web browser on any device and go to
http://your_pi_ip/admin. Log in with the password you set during installation. You’ll see a dashboard with statistics like total queries, blocked percentage, and top clients. - Configure your router to use Pi-hole as the DNS server. 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”). Change the DNS server address to your Pi’s IP address. If your router doesn’t allow custom DNS, you can instead disable DHCP on the router and enable DHCP on the Pi-hole (the installer can set this up). Save the settings and restart your router.
- Test your setup. After the router restarts, all devices should automatically use Pi-hole for DNS. Visit a website with ads—you should see fewer or no ads. To verify, go to the Pi-hole dashboard and check that queries are being logged.
- Optional: Set a static IP for your Pi. To prevent your Pi’s IP from changing after a reboot, set a static IP either in your router’s DHCP reservation or on the Pi itself. The Pi-hole installer usually configures this, but if not, edit
/etc/dhcpcd.confto add a static IP.
Common Mistakes
- Forgetting to update before installing. Skipping
sudo apt updatecan cause dependency issues during installation. - Not changing the router DNS. If you only install Pi-hole but don’t point your router to it, devices won’t use it.
- Using Wi-Fi for the Pi. Wi-Fi can be less reliable and slower; Ethernet is strongly recommended for a network service.
- Ignoring the static IP requirement. If your Pi’s IP changes, your router’s DNS setting will break, and you’ll lose internet on all devices.
- Blocking your own admin access. If you set up a firewall or blocklist too aggressively, you might block the admin dashboard. Make sure to allow the admin domain (usually
pi.holeor your Pi’s IP).
Tips
- Use a quality SD card. Cheap cards can fail quickly; choose a reputable brand like SanDisk or Samsung.
- Set up a DHCP reservation. In your router, assign a fixed IP to your Pi’s MAC address. This is more reliable than setting a static IP on the Pi itself.
- Customize your blocklists. You can add more blocklists from the Pi-hole admin dashboard under “Group Management” → “Adlists”. Popular lists include StevenBlack’s hosts and firebog.net.
- Enable the Pi-hole DHCP server. If your router doesn’t allow custom DNS, you can turn off DHCP on the router and enable it in Pi-hole. This gives you more control over network settings.
- Monitor logs regularly. Check the dashboard’s “Query Log” to see what’s being blocked and if any legitimate sites are being blocked accidentally.
- Update Pi-hole regularly. Run
pihole -upto update Pi-hole and its blocklists.
Troubleshooting
- No internet after setting router DNS. Double-check that your Pi’s IP is correct and that the Pi is online. Try
ping your_pi_ipfrom your computer. Also, ensure that your router’s DNS setting is pointing to the Pi’s IP, not its own. - Pi-hole dashboard not loading. Make sure the Pi-hole service is running:
sudo systemctl status pihole-FTL. If not, restart it withsudo systemctl restart pihole-FTL. Also ensure your Pi’s firewall allows port 80. - Ads still appearing. Some ads are served from the same domain as the content (e.g., YouTube ads). Pi-hole can’t block those without breaking the site. Also, some devices (like smart TVs) may have hardcoded DNS—you may need to set DNS manually on those devices.
- Devices not using Pi-hole. Check if your router is actually distributing the Pi-hole IP as DNS. You can verify by logging into a device and checking its DNS settings. On Windows, run
ipconfig /all; on macOS/Linux, runcat /etc/resolv.conf. - Pi-hole is slow. If the Pi is old (like a Pi 2), performance may be sluggish. Try using a lighter OS like Raspberry Pi OS Lite, or upgrade to a Pi 4/5. Also, ensure you’re using a good SD card.
- Can’t SSH into the Pi. Make sure SSH is enabled. If you didn’t enable it during flashing, you can enable it by creating an empty file named
sshin the boot partition of the SD card.
Frequently Asked Questions
- Does Pi-hole slow down my internet? No, it usually speeds it up because it blocks ads and trackers, reducing data usage and load times. The Pi itself handles DNS queries very quickly.
- Can I use Pi-hole with a VPN? Yes, you can set up a VPN (like WireGuard or OpenVPN) on your Pi and route all traffic through it, but that’s more advanced. Pi-hole works fine alongside a VPN.
- Will Pi-hole block all ads? It blocks most ads, but not all. Some ads are embedded in the content itself (e.g., sponsored posts) or served from the same domain as the content. You can combine Pi-hole with a browser ad blocker for better coverage.
- Can I use Pi-hole on a different device? Yes, Pi-hole can run on any Linux machine, a Docker container, or even a virtual machine. The Raspberry Pi is just a popular low-power choice.
- How do I uninstall Pi-hole? Run
pihole uninstallin the terminal. This will remove Pi-hole and restore your DNS settings to default. You may also need to change your router’s DNS back to your ISP’s or a public DNS. - Is Pi-hole safe? Yes, it’s open-source and widely used. It only blocks DNS queries to known ad and tracker domains. It doesn’t inspect or alter your traffic.