How to setup Pi-hole with Raspberry Pi Zero W?

After finding out how much it costs in the US to purchase the Raspberry Pi Zero W and combined with my longstanding desire to tinker and get my hands on a Raspberry Pi, even though I had no idea what I was gonna do with it, I ordered one from Argon40. With shipping, it added up to around S$20.

As I am usually quite annoyed by the rampant advertising encountered everywhere online, one of the first things I’ll download on my new devices (aside from the browser) is the amazing uBlock Origin. However, my family aren’t as savvy and while I do try to help them whenever I can, it can be quite cumbersome to do so for all their devices.

Naturally, the first project which came to mind is the Pi-hole, a network-level solution designed to block advertisements and trackers. I’ve gone through a number of tutorials but most of them are by the Raspberry Pi accessories sellers themselves which left me uncertain if I actually do need a certain component to get my Pi0 working.

What you really need:

Here’s my personal experience in the form of a simple, straightforward tutorial:

  1. Download and install Etcher
  2. Download the latest Raspbian Stretch Lite
  3. Insert and flash the microSD using Etcher. After the process is completed successfully, the microSD will be renamed boot and you will be able to view its system files.
  4. Create the file /boot/wpa_supplicant.conf. Replace YOURWIFINETWORKNAME and YOURWIFIPASSWORD appropriately.

    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev


  5. Edit /boot/config.txt. Add the following to the end of the file.

    # Enable UART

  6. Create /boot/ssh. Leave it blank.
  7. Eject the microSD safely and insert it into your Pi0. Connect the Pi0 PWR IN port to the router USB port. That will be serving as the Pi0’s power source.
  8. Wait for at least 2 minutes to allow the OS to boot. You can verify it’s working from the blinking green LED light on the Pi0.
  9. You can now SSH into your Pi0. The default password is raspberry.

    ssh [email protected]

  10. Run the following commands to update the system and configure your Pi0. Probably a good idea to change the password.

    sudo apt-get update
    sudo apt-get upgrade
    sudo raspi-config

  11. Install Pi-hole

    curl -sSL | bash

  12. The installer will ask a bunch of questions and it’s mostly fine to go with the defaults for now. If you’d like to take it a step further to enhance your privacy, you can follow this guide after to run your own recursive DNS server.
  13. It’ll probably take a while but once the installation finishes, take note of the web admin login URL and default password. You can change it immediately with the following command:

    pihole -a -p

  14. Login to your home network router’s admin panel (probably via Update the DNS 1+2 to use Pi-hole’s IP. I’m using Linksys’s and the settings can be found under Connectivity –> Local Network –> DHCP Server –> Static DNS. Save.
  15. Reboot any device connected to your network.
  16. That’s it. You should now have Pi-hole running on your network.
  17. To update Pi-hole and Gravity:

    pihole -up
    pihole -g

  18. If you need to temporarily disable Pi-hole for whatever reason, you can either do so via the administrative panel or the API:

    http://pi.hole/admin/api.php?disable=300&auth=[YOUR API AUTH KEY]

    You can retrieve the API key by logging into the administrative panel, navigate to Settings -> API/Web Interface and click the ‘Show API token’ button.

  19. Definitely check out a list of blocklists on Firebog to increase Pi-hole’s capability.

So simple!