December 4, 2025•7 min read••
Tags ▼
- Pi-Hole
- Unbound
- Quad9
- Ad-Blocker
- Ad-Blocking
- Raspberrypi
- Cloudflare
This tutorial demonstrates how to build a network-wide DNS filtering system using a Raspberry Pi 3 Model B (or newer) and Pi-hole, optionally enhanced with Unbound for fully local recursive DNS resolution.
To:
This guide provides a complete, reproducible deployment path from hardware flashing to recursive DNS resolution.
Required:
Download from: raspberrypi.com
Install and launch.
Inside Imager:
Click Customize:
pihole1netserveWi-Fi: Skip (using Ethernet)
Remote Access:
Raspberry Pi Connect: Disable
Click Write → wait for write + verify (~10 minutes total)
Insert SD card → Connect Ethernet → Power on.
Wait 2 minutes.
Check router client list
OR ping hostname:
ping pihole1
Record IP (e.g., 192.168.1.50)
On Windows:
Win + R
cmd
Connect:
ssh [email protected]
Enter password.
Run:
sudo apt update sudo apt upgrade -y
Preferred Method: Router DHCP Reservation
Why: If IP changes, DNS fails.
Alternative:
Edit /etc/dhcpcd.conf (not covered in tutorial)
Run official installer:
curl -sSL https://install.pi-hole.net | bash
Installer selections:
Static IP warning → Confirm
Upstream DNS → Select:
Blocklist → Enable Steven Black’s unified host list
Logging → No
Privacy mode → Level 0 (Show everything)
sudo pihole -a -p
Set password manually.
dig @192.168.1.50 www.google.com
If successful → DNS operational.
Reboot:
sudo shutdown -r now
In router settings:
⚠ Important: If secondary DNS is set, clients may bypass filtering.
Renew DHCP on one client or reboot device.
nslookup amazon.com
Check Pi-hole web UI:
http://192.168.1.50/admin
Look at Query Log.
If queries appear → Filtering active network-wide.
This removes dependency on third-party DNS providers.
sudo apt update sudo apt install -y unbound
sudo curl -o /var/lib/unbound/root.hints https://www.internic.net/domain/named.root
sudo nano /etc/unbound/unbound.conf.d/pi-hole.conf
Paste configuration from worksheet (standard Pi-hole recommended config).
Save:
CTRL + X Y Enter
sudo systemctl enable unbound sudo systemctl restart unbound sudo systemctl status unbound --no-pager
dig @127.0.0.1 -p 5335 cloudflare.com +dnssec +multi
Should resolve successfully.
In Pi-hole Web UI:
Settings → DNS
Uncheck public upstream providers
Custom IPv4:
127.0.0.1#5335
Save.
nslookup example.com
Verify in Query Log that upstream = 127.0.0.1
Client → Router → Pi-hole → Unbound → Root Servers
/etc/unbound/unbound.conf.d/pi-hole.conf/var/lib/unbound/root.hintssudo apt updatesudo apt upgrade -ysudo pihole -a -psudo systemctl enable unbounddignslookupUse wired Ethernet for reliability.
Never configure secondary DNS unless it’s a second Pi-hole.
Back up configuration regularly via:
Run updates monthly:
sudo apt update && sudo apt upgrade -y pihole -up
For redundancy:
Monitor logs periodically for unusual DNS activity.
If Pi goes offline → no DNS resolution.
Solution: Deploy dual Pi-hole setup.
Routers do NOT failover sequentially. They query all DNS servers simultaneously.
Some devices use:
These can bypass Pi-hole.
Mitigation:
Some IoT devices hardcode DNS servers. You may need firewall redirection rules.
A deep technical reference for DNS architecture, recursive resolution, caching behavior, and DNSSEC. Essential for understanding what Unbound is doing under the hood and how DNS resolution chains function.
Provides a strong foundation in Linux process management, networking, systemd services, and configuration files—critical for managing Raspberry Pi OS, SSH, and system services like Unbound.
Covers command-line operations, package management, service control, networking tools (dig, nslookup), and automation—directly relevant to maintaining Pi-hole infrastructure.
Teaches how DNS traffic flows across networks and how to analyze it with tools like Wireshark. Extremely useful for debugging DNS failures or verifying Pi-hole filtering behavior.
Explains reliability, redundancy, backups, monitoring, and high-availability patterns—valuable when expanding to dual Pi-hole deployments and production-style network services.
You now have a fully self-hosted DNS filtering and recursive resolution system. This is not just ad blocking — it’s a foundational network service deployment.
Follow on your preferred channel for new articles, notes, and experiments.