Pi-hole: Network-Wide Ad Blocking is the Best Thing I Didn’t Know About

My Raspberry Pi Zero W from two years ago, which was, for the best part of the aforementioned two years, sitting in my cupboard finally has a purpose: its a Pi-hole Network-Wide Ad Blocker!

I should mention that that Raspberry Pi has been through a LOT of projects. Initially bought for making a smart TV (fate: can’t run videos as its too weak), it went through projects for becoming an internet printer server (fate: neither the Pi nor the printer had ethernet), web server (fate: too weak), robot (fate: too complex, lack of parts, lack of knowledge, lack of interest), Minetest server (fate: too weak) and Nextcloud server (fate: too weak).

Anyways…

Pi-hole works by pretending to be a DNS server, which in reality just blocks known ad/malware related domains and sends the rest to an actual DNS server for resolving (see my first blog post for details on how DNS works). If your router is configured to use the Pi-hole as its DNS server, all the devices connected to that router will see less/no ads without actually installing an adblocker on every browser on every device. (many devices do not even support adblockers.)

Setup is super easy:

  1. Get a Raspberry Pi. I am using a Raspberry Pi Zero W as I said, and its seems to be powerful enough to handle Pi-hole, according to online sources.
  2. Get a supported distro. I did Raspbian, as most Raspberry Pi guides are written for it. I tried Debian (which I run everywhere, its the best distro in my opinion) but I couldn’t get to ssh into it via USB as the guide seemed to be dependent on a Raspbian-exclusive default. I probably could have gotten it to run, but it doesn’t matter that much I guess, as Raspbian is also based on Debian.
  3. Run the Pi after connecting it to a monitor and keyboard. You need to do this at least once to set up WiFi. (I had to look up an online tutorial for this.)
  4. Run their one line setup script. It isn’t mentioned on their site, but use it via root or sudo, or else it won’t be able to install dependencies or edit system files.
  5. In the setup, I used my router’s default DNS servers, but you can use any other DNS servers as the Pi-hole’s DNS servers. It provides a list of popular ones to choose from easily as well.
  6. Set the Pi-hole’s local IP address as the default DNS server in your router, or set the Pi-hole’s local IP address manually in the settings of the devices you want to use adblock with as the DNS server. (I went network-wide, as some devices do not support this functionality.) It is listed under DHCP settings, or something similar. (I wish there was some sort of coordination between router companies as to naming conventions, but nooooo. I wonder how these guys manage to basically run the internet.)
  7. ???
  8. Profit. (See Linus Tech Tips’ video here for additional details.)

Setup was super easy: I didn’t have access to a HDMI screen so I had to ssh into it through USB and set it up. I advise anyone using Raspbian to not use network-manager – Raspbian doesn’t like it. I did have the usual hitches in the way of any project, like the Debian thing I mentioned and WiFi not working initially. But not much else caused trouble. I soon added several more blacklists (they are available online), and it seems to work really good at the moment. I will make it a point to keep this post updated with any further issues I may get, and how I fix it.

It should be noted that if your Raspberry Pi shuts down unexpectedly or faces some other issue, either the entire network (if you go network-wide) or the devices configured to use Pi-hole will not have internet unless to DNS settings are changed. Connect the Pi to an inverter/ generator/ UPS powered plug point.

One thought on “Pi-hole: Network-Wide Ad Blocking is the Best Thing I Didn’t Know About”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.