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: Install & Setup Guide

Pi-hole turns a Raspberry Pi into a network-wide ad blocker. Instead of installing an ad blocker on every phone, laptop, and tablet, Pi-hole runs at the router level and filters out ads, trackers, and malicious domains before they ever reach your devices. It also gives you a detailed dashboard showing exactly what your network is trying to contact. This guide walks you through installing Pi-hole on a Raspberry Pi running Raspberry Pi OS (formerly Raspbian), from flashing the SD card to logging into the admin interface.

What You’ll Need

  • A Raspberry Pi (any model from the Pi 2 onward works; the Pi Zero 2 W is fine for most homes)
  • A microSD card (at least 8GB, Class 10 recommended) and a way to write to it from your computer
  • A power supply for the Pi (official one recommended)
  • An Ethernet cable or reliable Wi-Fi connection
  • A computer on the same network to access the Pi’s terminal and web interface
  • Optional: a USB keyboard and HDMI monitor for initial setup, though headless setup is covered

Step-by-Step

  1. Flash Raspberry Pi OS to the SD card. Download the Raspberry Pi Imager from the official Raspberry Pi website. Insert your SD card into your computer, open the Imager, choose your Pi model, select “Raspberry Pi OS (32-bit)” (the Lite version is fine if you don’t need a desktop), and choose your SD card. Click “Write” and wait for it to finish.
  2. Enable SSH for headless setup (optional but recommended). After flashing, the SD card will appear as a drive called “boot”. Create an empty file named ssh (no extension) in that drive’s root folder. This allows you to connect remotely via SSH. If you want Wi-Fi, also create a file named wpa_supplicant.conf with your network details (see the Raspberry Pi documentation for the exact format).
  3. Boot the Pi and find its IP address. Insert the SD card into the Pi, connect power, and wait a minute. On your computer, open your router’s admin page (usually at 192.168.1.1 or 192.168.0.1) and look for connected devices, or use a network scanner app. The Pi should appear with a hostname like “raspberrypi”. Note its IP address (e.g., 192.168.1.42).
  4. Connect to the Pi via SSH. Open a terminal (on Windows, use PowerShell or PuTTY). Type ssh pi@ (replace with the actual IP). The default password is raspberry. If you enabled Wi-Fi but it didn’t connect, check the wpa_supplicant.conf file for typos.
  5. Update the system. Run these commands one by one:
    sudo apt update
    sudo apt upgrade -y

    This ensures your Pi has the latest security patches and packages. It may take a few minutes.

  6. Run the Pi-hole installer. In the SSH session, run:
    curl -sSL https://install.pi-hole.net | bash

    The installer will guide you through several prompts. Accept the default choices unless you have a specific reason to change them. When asked about the upstream DNS provider, choose one you trust (e.g., Google, Cloudflare, or your ISP’s).

  7. Set a static IP address. The installer will ask if you want to set a static IP. Choose “Yes” and follow the on-screen instructions. This is crucial so your router always knows where to send DNS requests. If you skip this, your Pi might get a new IP later, and Pi-hole will stop working.
  8. Note the admin password. At the end of the installer, it will display a randomly generated admin password. Write it down. You’ll need it to log into the web interface.
  9. Log into the Pi-hole dashboard. Open a web browser on any device on your network and go to http:///admin. Enter the admin password you noted. You’ll see the dashboard with stats like queries blocked and top clients.
  10. Configure your router to use Pi-hole as DNS. This is the final step. Go to your router’s settings, find the DHCP or DNS section, and set the primary DNS server to the Pi’s IP address. You can leave the secondary blank or set it to a public DNS like 8.8.8.8 as a backup. Save the settings and reboot your router if needed. After that, all devices on your network will use Pi-hole for DNS.

Common Mistakes

  • Forgetting to set a static IP. If you skip this, your Pi might get a new IP after a reboot, and your router will still point to the old one, breaking ad blocking.
  • Using the wrong network interface. If your Pi is connected via Ethernet, make sure you set the static IP on eth0, not wlan0. The installer usually asks, but double-check.
  • Not updating before installing. An outdated system can cause dependency issues. Always run sudo apt update && sudo apt upgrade first.
  • Setting the router DNS but not rebooting devices. Existing devices may keep using the old DNS until they renew their DHCP lease. Reboot your devices or wait a few hours.
  • Blocking your own router. If you set the router’s DNS to the Pi, but the Pi uses the router as its upstream DNS, you create a loop. Make sure the Pi’s upstream DNS is a public server, not your router’s IP.

Tips

  • Use a wired Ethernet connection for the Pi if possible. Wi-Fi can add latency and is less reliable for a network service.
  • Back up your Pi-hole configuration regularly. You can do this from the dashboard under Settings > Teleporter, which exports a backup file.
  • Add more blocklists to increase coverage. The default list is good, but you can add lists from the Pi-hole community (e.g., from the “firebog.net” curated list) under Group Management > Adlists.
  • Set up a cron job to update the blocklists weekly. The installer does this automatically, but you can adjust the frequency in /etc/cron.d/pihole.
  • Use the Pi-hole app or a browser extension to quickly whitelist a domain if you notice a false positive (a site that breaks because it relies on a blocked domain).

Troubleshooting

  • Can’t access the admin page. Check that the Pi is on and connected to the network. Ping the Pi’s IP from your computer. If it doesn’t respond, check the Ethernet cable or Wi-Fi settings. Also, make sure your browser is using the correct URL: http:///admin (not https).
  • Pi-hole is running but ads still appear. Your router might not be using Pi-hole as DNS. Verify the router settings. Also, some devices (like smart TVs) have hardcoded DNS servers that bypass your router. You can override this by setting Pi-hole as the DNS on each device manually.
  • Network is slow after installing Pi-hole. This is usually due to a slow upstream DNS. Change the upstream DNS in Pi-hole settings to a faster one (e.g., Cloudflare 1.1.1.1 or Google 8.8.8.8). Also, check that your Pi is not overloaded; the Pi 2 or older might struggle with heavy traffic.
  • Forgot the admin password. You can reset it by running sudo pihole -a -p in the terminal and following the prompts.
  • Pi-hole stops working after a reboot. This often means the static IP wasn’t set correctly. Run sudo pihole -r to reconfigure Pi-hole and choose the static IP option again.
  • DNS resolution fails entirely. Check that the Pi can reach the internet: ping 8.8.8.8. If that works, try nslookup google.com to see if DNS is working. If not, check the upstream DNS settings in Pi-hole.

Frequently Asked Questions

Will Pi-hole slow down my internet?

No, in most cases it speeds up browsing because it blocks ads before they load, reducing data usage. The Pi itself is fast enough for typical home networks (up to a few hundred devices). The only bottleneck could be a slow upstream DNS, which you can change.

Can I use Pi-hole with a VPN?

Yes. If you run a VPN on your router or Pi, you can configure Pi-hole to handle DNS for VPN clients as well. Some setups use Pi-hole as the DNS for the VPN interface, which works well.

Does Pi-hole block YouTube ads?

No, Pi-hole cannot block ads that are served from the same domain as the video content (like YouTube). It can block some pre-roll ads, but not the in-video ones. For that, you’d need a browser extension or a different tool.

Can I run Pi-hole on a different device, like a Docker container?

Yes, Pi-hole can run in Docker on any Linux machine, or even on Windows with WSL2. The installation steps differ, but the configuration and features are the same. This guide focuses on Raspberry Pi, but the principles apply elsewhere.

How do I update Pi-hole?

Run sudo pihole -up to update Pi-hole itself, and sudo pihole -g to update the blocklists. You can also enable automatic updates in the dashboard under Settings > System.

Can I use Pi-hole with a mesh Wi-Fi system?

Yes, as long as you can set a custom DNS server in the mesh router’s settings. Some mesh systems have a dedicated field for DNS; others require you to set it per node. Check your router’s documentation.

Pi-hole on Raspberry Pi: Install & Setup Guide
Scroll to top