Elevating Network Security and Privacy with Raspberry Pi-Powered Ad Blocking
Imagine your online presence as a series of footsteps in a digital forest. Every click and search is a digital step, meticulously recorded, shaping personalized advertisements. Now, picture a shadow silently following these footsteps, noting every nuance of your journey. This isn’t a scene from a cyber-thriller; it’s the world of targeted advertisements. Behind the scenes, your digital trail is meticulously tracked, creating a detailed online profile that not only shapes the ads you see but, in the wrong hands, could reveal more about you than you ever intended. Welcome to the crossroads of personalization and privacy, where each online step leaves a trace, and the question becomes: Who is silently watching, and what stories do your digital footsteps tell?

In 2023, global ad expenditure reached over $600 billion and is expected to reach 10.5% year-over-year increases throughout the coming years (Cramer-Flood, 2023). The prevalence of these online targeted advertisements not only compromises user privacy through data collection and tracking, but presents itself with security risks. To address this, many of us resort to browser extensions, such as Adblock. While adblockers excel at blocking ads within your web browser, consideration must be given to all devices on a network. Pi-hole extends this consideration by functioning as a network-wide ad blocker, creating a digital sanctuary where your entire online experience, from streaming on your smart TV to browsing on your smartphone, is seamlessly shielded from the intrusion of unwanted advertisements, tracking, and potential malware.
Table of Contents
Project Purpose
This Pi-hole project aimed to implement a solution to block ads at the network level for all devices in order to address the privacy concerns involved with our online footprints and enhance understanding of privacy/tracking awareness, and network security. Additionally, this project offered a chance to acquire practical experience in configuring and managing a DNS server, along with hands-on experience with networking concepts related to router configuration, DHCP, and IP addressing.

Tools and Technologies Employed
- Raspberry Pi 4 + Power Supply
- Access to a configurable router (with an ethernet port)
- Ethernet cable (connecting the Pi to the router)
- Raspbian OS / Linux OS
- Pi-hole software
- DNS / DHCP / IP Address Leasing
- SSH (for remote management)
Results Achieved
The implementation of Pi-Hole provided the following accomplishments:
- Minimized exposure to online tracking and profiling by implementing trusted ad lists targeting:
- Advertising
- Tracking
- Telemetry
- Malware domains / Malicious sites
- Enhanced network-wide protection and bolstered security posture by implementing secure configurations on a Raspberry Pi while concurrently restricting access to potential malicious domains.
- Provided insight into configuring Pi-Hole’s as both a DNS server and DNS sinkhole, blocking ads by intercepting DNS requests and preventing DNS resolution for blacklisted sites/domains.
Once fully set up, the Pi-Hole dashboard becomes a very friendly user interface that provides one with an abundance of statistics and visualizations. Various dashboards and data filters can be created to view both short-term and long-term data for the queries collected from your local network.



After running for approximately 1 month, the Pi-Hole has shown great success in speeding up network queries and blocking additional ads/tracking for various sites and applications, reaching an average of 14% of ads blocked at the network level and utilizing less than 5% of the Raspberry Pi’s total memory usage.
Challenges Faced and Solutions Implemented
Missing Configuration File
The first challenge that encountered during the initial setup involved a missing configuration file that was needed to configure a static IP address on the Raspberry Pi. The purpose of assigning a static IP address was to maintain a consistent address, guaranteeing that others devices consistently connect to the correct location. To establish the static IP on the Raspberry Pi through the command line, it was necessary to access the dhcpcd.conf file, achieved by executing the following command:
$ sudo nano -w /etc/dhcpcd.conf
However, upon executing this command, the command yielded a blank page, indicating the absence of the dhcpcd.conf file.
After conducting some troubleshooting and research, it was found that starting from Debian Bookworm version dated 10/10/2023, Debian/Raspberry Pi OS no longer employed dhcpcd as its networking interface. The change was identified in the Raspberry Pi OS release notes:
2023-10-10:
* NetworkManager used instead of dhcpcd as networking interface; various changes made to networking plugin to support this
To resolve this, it was found that installing the dhcpcd5 package via the command line was required in order to have the necessary components for DHCP configuration to continue the project. Once this was done, we are able to run the same command from above (instead for dhcpcd5) to access and edit the new conf file.
$ sudo apt-get install dhcpcd5
$ sudo nano -w /etc/dhcpcd5.conf
We are then able to add in the needed configuration settings to set the needed static IP addresses:

(Blocking) More is not always better
Another crucial consideration arose during the setup—balancing aggressive ad blocking with the necessity for legitimate website access. Many blocklists overlap, and incorporating too many can lead to unnecessary redundancy, wasting efficiency and resources. Moreover, there were instances where authorized access to essential domains was hindered due to the implemented ad blocking. In other words, many false positives occurred, hindering basic web browsing functionality. Not ideal!
To address this issue, Pi-hole settings were refined through (1) managing adlist groups and (2) whitelisting domains based on query log analysis within the Pi-hole dashboard. This can be done by manually adding domains for blacklisting/whitelisting via the domain management page, or by visiting the query log analysis page as shown below:

Closing Thoughts
Configuring and managing Pi-Hole successfully has expanded my understanding of computer networking management and configuration, network privacy and security, as well as DNS/networking traffic logging and analytics. Recognizing the worth of this network-wide ad-blocking solution was a valuable outcome of this project. It has offered me valuable insights into developing a mindset for implementing security measures, analyzing potential risks, and understanding the significance of privacy and network security on a local area network – all while enabling me to implement a solution to enhance cybersecurity for end-users.
Although originally designed for Raspberry Pi, the Pi-Hole’s efficiency and lightweight design seem to make it perfect for installation on different systems. This project has inspired me to implement Pi-Hole on platforms like virtual machines or Docker containers, offering another potential project implementation.
Source Citations
Christner, B. (2022, January 9). How a Single Raspberry PI made my Home Network Faster. BrianChristner.io. https://brianchristner.io/how-a-single-raspberry-pi-made-my-home-network-faster/
Cramer-Flood, E. (2023, October 13). Worldwide Digital Ad Spending 2023. Insider Intelligence. https://www.insiderintelligence.com/content/worldwide-digital-ad-spending-2023
Stihy. (2022, September 17). Raspberry Pi 4: Review, buying guide and how to use. Tom’s Hardware. https://www.tomshardware.com/reviews/raspberry-pi-4