NETWORK AD BLOCKER ON A RASPBERRY PI ZERO W

What is Pi-Hole? and how does it work?
Pi-hole is open-source software that acts as a DNS sinkhole to protect your devices from unwanted content, without the need for any client-side software like apps or browser plug-ins. PiHole blocks ads using blocklists which check against a database of known ad serving domains. This way, it blocks ads not only in browsers, but also mobile apps and smart TVs — and it makes your network faster!
What You Need to Make Your Own Pi-Hole Ad Blocker
Full Kit:
- RaspberryPi Zero W Complete Kit – Here
Individual Components:
Configuring the RaspberryPi
Pi-Hole is most installed on a raspberrypi, here is the Prerequisites for reference.
Install Raspberry Pi OS
-
Download the latest Raspberry Pi Imager here
-
Pick Operating System: Raspberry Pi OS (32-BIT)
-
Insert your microSD card in to the card reader on your computer.
-
Click Write. Then when Imager is done, you will see
-
DO NOT FORMAT THE PARTITION, click ‘Cancel’.
-
You should see a new boot SD card mounted on your computer.
Configure Raspberry Pi OS
Enable SSH Access
Create an empty file called ssh
on the new partition “boot” of the microSD card.
- Windows
- In Windows, the easiest way to do this open Windows Explorer and navigate to the boot partition.
- To do this right-click in the root of the folder, select New->Text File Document and then call it
ssh
(no .txt extension)
- Mac OS or Linux
- use the terminal to change the root of the boot partition,
- and run touch
ssh
to create the file.
Add a wpa_supplicant.conf file to the boot partition.

- Open up the wpa_supplicant.conf file and add the following script to it.
|
|
- Unmount the SD card and insert it to your Raspberry Pi.
Connect RaspberryPi to the network
Plug in the raspberryPi, and connect it to the network then figure out the Raspberry PI newly assigned address by using a network Scanner Angry IP Scanner
Once you know the Raspberry Pi newly assigned IP address, test your connection in command line by running Ping command. Now you can SSH to your raspberry pi by using Putty, or windows terminal.

The default username and password of Raspberry Pi:
Username : Pi
Password : Raspberry
Once you successfully log in, screen will look like:
run the following command sudo raspi-config
and update the following:
- Update the default password for Pi
- Update hostname from raspberrypi
Configuring Pi-Hole on RaspberryPi
While still connected to Raspberry Pi, now run the Pi-Hole install command: curl -sSL https://install.pi-hole.net | bash

then the Pi-Hole installer screens will begin

Once the installer begins you will see something similar to (Select ‘yes’ for installing ‘Web Admin Interface’ and ‘log queries’):

Pi-hole needs a static IP to function properly

Ethernet is recommended here for reliability

Quad9 for Upstream DNS

Enabling 3rd party blocklist

Leave Protocols as default

Confirm the static IP configuration


Install Pi-hole web dashboard

Install lighttpd web server

It is recommended to enable the log queries

Show Everything

Installation is complete. Please note down the password displayed on this screen because this will be the password that we will use to login to the web dashboard.

pihole -a -p
sudo reboot
pi-hole -h
or checkout this pageNow the Pi-Hole is functional, you can try login in to the admin web portal
To access the Pi Hole admin web UI, navigate to http://[Pi-Hole device IP address]/admin/

Configuring Network-Wide AD Blocker Settings
- Log into your internet gateway as an administrator.
- Locate the DHP server setting page, and set the primary DNS server to be the IP address of your Pi-Hole you configured earlier.
- Set the secondary DNS Serever to 1.1.1.1 (Cloudflare) or 8.8.8.8 (Google)
- Save the setting on the router, and reboot all your devices and that’s it!
You’ve now got the basic Pi-Hole Ad Blocking enabled for your entire network!
Conclusion
At the end, Pi Hole is an easy to set up nifty piece of software which can simplify ad blocking and domain tracking. It comes with a cool dashboard providing different statistics of your network and the ads being blocked. So, it will be very convenient to manage as well. Certain sites might not display properly. Moreover, many websites featuring quality content rely on ads for revenue, so if you like a certain website, consider whitelisting them in your Pi Hole backend.