Pi-hole is a network-wide ad blocker that runs on a Raspberry Pi. Instead of blocking ads on a single device, it filters DNS requests for your entire home network, so every phone, laptop, and smart TV gets ad-free browsing and faster load times. It also blocks trackers and can improve privacy. This guide walks you through setting up a Pi-hole from scratch, from flashing the OS to configuring your router.
What You’ll Need
- A Raspberry Pi (any model from the Pi 3 onwards works well; Pi Zero 2 W is also fine)
- A microSD card (at least 8 GB, Class 10 recommended)
- A power supply for your Pi (official one is best)
- An Ethernet cable (recommended for reliability) or Wi-Fi capability
- A computer to write the SD card and access the Pi
- An SD card reader (if your computer lacks a built-in slot)
- Optional: a case, heatsink, and a USB keyboard/mouse for initial setup
Step-by-Step
- Flash Raspberry Pi OS onto the SD card. Download the Raspberry Pi Imager from the official Raspberry Pi website, install it on your computer, and run it. Insert the SD card, choose your Pi model, select “Raspberry Pi OS (32-bit)” (Lite is fine, no desktop needed), and choose the SD card as the target. Click “Write” and wait for it to finish.
- Enable SSH (optional but recommended). After flashing, the SD card will appear as a drive named “boot”. Create an empty file named
ssh(no extension) in that drive’s root folder. This allows you to connect remotely later. - Boot the Pi and connect it to your network. Insert the SD card into the Pi, connect an Ethernet cable (or set up Wi-Fi via the Imager’s advanced options), and plug in the power. Wait about 30 seconds for it to boot.
- Find the Pi’s IP address. If you have a monitor and keyboard, log in with the default credentials (username
pi, passwordraspberry) and runhostname -I. Otherwise, check your router’s admin page for connected devices, or use a network scanner app. - Connect via SSH (if enabled). From your computer, open a terminal (or use PuTTY on Windows) and type
ssh pi@<IP_ADDRESS>. Enter the password when prompted. - Update the system. Run
sudo apt updateand thensudo apt upgrade -y. This ensures you have the latest packages and security fixes. - 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), and accept the default blocklists. - Set a static IP address. After installation, you’ll see the Pi-hole’s IP address and a randomly generated admin password. It’s crucial to set a static IP on your router (either via DHCP reservation or by editing the Pi’s network config) so the Pi-hole address never changes.
- Access the admin dashboard. Open a web browser on any device and go to
http://<PI_IP>/admin. Log in with the admin password. You’ll see a dashboard with query stats, top clients, and blocking percentages. - Change your router’s DNS settings. Log into your router’s admin panel (usually at 192.168.1.1 or similar). Find the DHCP or DNS settings and set the DNS server to the Pi-hole’s IP address. If your router has a “DNS Server” field, put the Pi-hole IP there. If it has a “DHCP” section, set the DNS that is handed out to clients to the Pi-hole IP. Save and reboot the router.
- Test the setup. On a device connected to your network, visit a website with ads (e.g., a news site). You should see fewer or no ads. Check the Pi-hole dashboard to see blocked queries increasing.
Common Mistakes
- Not setting a static IP: If the Pi’s IP changes, devices can’t find the Pi-hole, and your internet may stop working.
- Using the wrong DNS field in the router: Some routers have separate fields for “DNS Server” and “DHCP DNS”. You need to set the DNS that is handed out to clients, not just the router’s own DNS.
- Forgetting to update the system before installing: This can cause dependency issues.
- Using a microSD card that is too slow or too small: This can cause performance problems and crashes.
- Not rebooting after changing router settings: Some routers need a reboot to apply DNS changes.
Tips
- Use a wired Ethernet connection for the Pi-hole for maximum reliability and speed.
- Enable the “Pi-hole’s built-in DHCP server” if your router doesn’t allow you to change the DNS handed out. You’ll need to disable DHCP on your router first.
- Add extra blocklists from the Pi-hole “Adlists” section in the admin panel to block more trackers and ads.
- Update Pi-hole regularly with
pihole -upto get new features and blocklist updates. - Set a strong admin password using
pihole -a -p. - Monitor your network’s DNS queries to see which devices are requesting the most (and potentially spot malware).
Troubleshooting
- Internet stops working after setting Pi-hole as DNS: This usually means the Pi-hole is not reachable. Check that the Pi is on and the IP is correct. Try pinging the Pi-hole from another device. If it fails, check the network cable and reboot the Pi.
- Pi-hole dashboard is not loading: Ensure you’re using the correct IP and that the Pi-hole service is running with
sudo systemctl status pihole-FTL. If it’s not, start it withsudo systemctl start pihole-FTL. - Some devices still show ads: Some devices (like smart TVs) may have hardcoded DNS or use their own DNS. You may need to set the DNS manually on those devices to the Pi-hole IP.
- Pi-hole is blocking too much (or not enough): Adjust the blocklists in the admin panel. You can whitelist domains that are incorrectly blocked, or add more aggressive lists.
- Forgot the admin password: Run
sudo pihole -a -pto set a new one.
Frequently Asked Questions
Will Pi-hole slow down my internet?
No, it usually speeds it up because it blocks ads and trackers before they load, reducing bandwidth usage and page load times.
Can I use Pi-hole on a Wi-Fi connection?
Yes, but a wired connection is more stable and faster. If you use Wi-Fi, make sure the Pi is close to your router.
Does Pi-hole work with IPv6?
Yes, Pi-hole supports IPv6, but you may need to configure your router to use the Pi-hole’s IPv6 address as DNS.
Can I run Pi-hole alongside other services on my Pi?
Yes, you can run Pi-hole alongside other lightweight services like Home Assistant or a VPN, but be mindful of the Pi’s resources.
How do I update Pi-hole and its blocklists?
Run pihole -up to update Pi-hole itself, and pihole -g to update the blocklists.
Can I use Pi-hole with a VPN?
Yes, you can combine Pi-hole with a VPN like WireGuard or OpenVPN to block ads on the go. There are many guides online for this.