Date
Jun. 13rd, 2025
 
2025年六月三十

Post: Trying out Pi-Hole with a Raspberry Pi Zero

Trying out Pi-Hole with a Raspberry Pi Zero

Published 13:06 Jun 08, 2022.

Created by @ezra. Categorized in #UNIX/Linux.

Source format: Markdown

Table of Content

Parts List

  • Raspberry Pi (any model): I will be using a Raspberry Pi Zero
    • You can optionally install Pi-Hole in a docker container, or inside a VM, but we will be assuming you are using a Raspi for the rest of this tutorial.
  • Micro SD Card (2gb+, but you should probably just buy a 16GB card because they're so cheap)
  • 2.5A Micro USB AC Power Supply
  • *Optional*: Micro USB to RJ45 Ethernet Adapter
    • This is in case the RasPi you are using doesn't have an ethernet port or WiFi (if you're using the Pi Zero, you will need one of these)
  • *Optional*: Other stuff that you might need:
    • SD/uSD Card Reader (Unless your laptop, or you already has one)
    • Ethernet Cable (Unless you're using WiFi, you will need one of these)
    • Case for your Raspberry Pi Model (Nice to have to keep it protected, but cardboard also works)
    • Heat sinks for your Raspberry Pi (Nice to have to keep it cool, also helpful if you want to overclock your Pi)
    • A display connection for your Pi (Pi Zero's use Mini HDMI) (We will be doing a headless install, so this is not necessary)

Stage 1 - OS Install/Setup

Before we can install Pi-Hole or anything else really, we have to setup our operating system.

If you're doing a headless install like us (no monitor/keyboard required), you'll need to enable SSH before booting up the Raspberry Pi * Replug your uSD card to allow Windows to recognize the new Raspbian partition layout * You should have drive labeled as "boot" * Create a file inside the "boot" folder called "ssh" with no extension

Plug your uSD card into the Raspberry Pi followed by networking, and then power.

Since we're doing a headless install, we'll need to search for our raspberrypi's IP address so we can access it over SSH.

  • If you know what you're doing, log in to your router's admin page and check the DHCP client/reservation list for "raspberrypi"
  • If you don't know how to do the above, download Angry IP Scanner and run it: https://angryip.org/
  • Look for the hostname "raspberrypi", on that line the IP and MAC address of our Raspberry Pi will also be listed: 10.20.0.77 in our case

Now that we've found our Raspberry Pi's IP address + MAC Address, we need to assign it an INTERNAL/LOCAL static IP address.**

  • This process is going to vary wildly based on which router/DHCP server you use, so we'd recommend Googling your router's model name/number (can be found on the back) + "how to set static IP" (ex: "Netgear R7000 how to set static ip").
  • If you're willing and somewhat tech savvy, you might also be able to figure it out on your own.
    • Start by navigating to your router's admin page. The IP for this is typically located on a sticker on the back of your ISP's provided router (along with the admin page's default username and password).
      • You can also find it by running the command "ipconfig" in command prompt on a Windows PC. Your router's IP will be listed after "Default Gateway".
    • Log in to the admin page either with the login credentials listed on the back of the router, or by googling the model number of the router along with "default password". Some routers use a randomly generated default password, so googling will not work for those.
    • Once logged in, look for a tab labeled "DHCP Reservation", "Static IP Assignment", or something along those lines. You may have to go to the Advanced menu to access this.
    • Enter the MAC address we grabbed earlier with Angry IP scanner, and then enter/select your desired static IP address (make sure you're using something not taken by another device on your network).
    • Hit Apply (or whatever the equivalent is for your router) 

Re-plug the power connection for your Raspberry Pi, to allow it to restart and fetch it's newly assigned IP.

To access the Raspberry Pi over SSH we will need to download and connect to it with an SSH client.

  • Download, install and then launch the SSH client of your choice.
    • Any SSH client will do, such as PuTTY: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
    • Enter the newly assigned static IP address of your Raspberry Pi into PuTTY, and click "Open".
    • After it prompts you with "login as:" enter "pi".
    • Then for password, enter "raspberry". You should now be logged in over SSH.

Now that we're logged in over SSH, start by changing the default password, and updating the Raspberry Pi.

  • To change the user password enter the command "passwd" and press enter. You'll then be prompted to enter the current password (this is "raspberry" so enter that). Then enter your desired new password.
  • To update the Raspberry Pi, run the command "sudo apt update" - this is going to update the package list to tell us if anything needs to be update.
    • Then, to actually upgrade the packages now that the package manager knows which ones need updating, run "sudo apt upgrade -y".

Our Raspberry Pi is now updated, set to a secure password and ready to install Pi-Hole onto!

Stage 2 - Pi-Hole Install/Setup

With our RasPi's OS, internet, and SSH ready to go, we can now install Pi-Hole.

  • Copy the Pi-Hole install command from their website, paste it into the SSH client, and click Enter to run it: https://github.com/pi-hole/pi-hole/#one-step-automated-install.
    • curl -sSL https://install.pi-hole.net | bash
  • The installer will spit out some status updates until you're brought to the configuration screen.
  • Press Enter until you get to the "Choose An Interface" page. The default "eth0" interface for Ethernet users should be selected by default. Press Enter to continue.
    • ("wlan0" should be selected if you're using WiFI - keep in mind WiFi installation is not supported in this tutorial, but if you have some decent Google-Fu you should be able to figure it out)
  • On the next screen, select your upstream DNS provider. This is where requests will be forwarded if they're not blocked by Pi-Hole (ie. if they're not found in it's block/black lists). We will be using Google DNS, and if you don't know what this means, stick with that. Press Enter to continue.
  • The following screen allows you to select which of the default block list's you'd like to use. We will leave these all on, but you can use your arrow keys and space bar to (de)select any of them as you wish. Press Enter to continue.
  • Next up, it will ask you if which IP protocols you want to block ads over, leave this at the default unless you know what you're doing. Press Enter to continue.
  • The next screen will list the IP address of the Raspberry Pi and the IP of your router, assuming you've set a static IP, just click Enter to continue.
    • If you get a screen about an IP conflict, just ignore it and click Enter to continue.
  • You'll then be asked about the web interface, web server, and logging modes. Leave these all at default by clicking Enter.
  • After all that, Pi-Hole is going to do a bunch of stuff, and it might take a couple minutes so sit back until you're greeted with an "Installation Complete!" page. This will list the IP and password for the Pi-Hole web interface.

Copy the IP into your browser, and log with the listed password. Huzzah! You now have a functioning Pi-Hole installation.

Stage 3 - Setting Up Pi-Hole to Run on Your Devices / Whole Network

To enable Pi-Hole on a device-by-device basis, you'll need to manually set the DNS IP address in your device settings.

  • For each of these, substitute the IP in the tutorial for the IP of your Raspberry Pi

To enable Pi-Hole on a Router level, meaning it will work on all your devices automatically, you'll need to configure your router's DHCP server's default DNS settings.

  • This process is going to vary wildly based on which router/DHCP server you use, so we'd recommend Googling your router's model name/number (can be found on the back) + "how to set DNS servers" (ex: "Netgear R7000 how to set DNS servers").

Stage 4 - Using Pi-Hole + Common Whitelisting

pizero

picard

piac

Pinned Message
HOTODOGO
The Founder and CEO of Infeca Technology.
Developer, Designer, Blogger.
Big fan of Apple, Love of colour.
Feel free to contact me.
反曲点科技创始人和首席执行官。
开发、设计与写作皆为所长。
热爱苹果、钟情色彩。
随时恭候 垂询