Today's personal endeavor was setting up a Pi-hole to block unwanted content for all devices connected to my home network.
How it works #
For anybody unfamiliar, I'll briefly explain how a Pi-hole works:
The Pi-hole acts as a sole (single) local DNS server, configured with a blacklist of domains which are known for serving ads and other unwanted content (such as trackers). This way, whenever an application (such as a web browser, or even a game on one's smartphone) needs to fetch external content, then the process starts by attempting to resolve the serving domain; if the domain is in the Pi-hole's blacklist then the Pi-hole doesn't return the content.
The importance of a Pi-hole being the sole DNS server on the network is so that when queries for unwanted content are blocked, there should not be an alternative DNS server to fall-back on, which would succeed at resolving the queries for unwanted content.
Deployment #
I deployed my Pi-hole server as a Docker container, running on a Raspberry Pi 4. Specific instructions about this can be found on the Pi-hole page at DockerHub. The docker-compose.yaml file contains:
1version: "3"
2services:
3 pihole:
4 container_name: pihole
5 hostname: 'pi.hole'
6 image: pihole/pihole:2026.07.2
7 network_mode: host
8 environment:
9 TZ: 'Israel'
10 PIHOLE_DNS_: '1.1.1.1;1.0.0.1'
11 DNSSEC: 'true'
12 VIRTUAL_HOST: 'pi.hole'
13 volumes:
14 - './etc-pihole/:/etc/pihole/'
15 - './etc-dnsmasq.d/:/etc/dnsmasq.d/'
16 cap_add:
17 - NET_ADMIN
18 restart: unless-stopped
Router configuration (DHCP and DNS) #
In my router I reserved the Raspberry Pi's IP address' DHCP lease (so that it wouldn't have the chance to change in case of a restart, etc.), and configured the router's DNS nameserver to use the Raspberry Pi's IP address, which serves the Pi-hole - instead of the one automatically acquired from one's ISP.
Note that the Secondary DNS field must remain empty!
DHCP Reservation Lease Infos #
| # | MAC Address | IP Address |
|---|---|---|
| 1 | dc:a6:32:16:70:00 | 192.168.1.19 |
Pi-hole configuration (local DNS record) #
In the Pi-hole I optionally chose to configure a local DNS record to map the domain name pi.hole to its [reserved] IP address. This allows me to access the Pi-hole's front end dashboard (which it exposes automatically) via a comfortable domain name, instead of its raw IP address.
Conclusion #
In conclusion, this is a neat project which involves a nice handful of network and internet theory, bundled into an elegant solution for an everyday problem.
There is one major caveat with this solution, in regards of blocking ads: it doesn't work for ads in YouTube videos. The reason for this is because the ads are served from the same domains as the actual video content. Therefore, if one's a frequent consumer of YouTube, then they should consider using a browser-based ad-blocker plugin in addition to a Pi-hole.