Why Pair Pi-hole with Unbound Recursive DNS?
Running Pi-hole as your home network DNS server provides immediate, network-wide ad blocking, telemetry suppression, and malware domain filtering across all connected devices (smart TVs, mobile phones, IoT appliances, and laptops) without requiring client-side extensions.
However, standard Pi-hole installations forward upstream DNS queries to commercial providers like Google (8.8.8.8) or Cloudflare (1.1.1.1). While encrypted options (DoH / DoT) hide DNS queries from your ISP, upstream providers can still build profiling data from your domain requests.
Standard Setup:
Device -> Pi-hole (Filter) -> Cloudflare/Google (Logs queries) -> Authoritative Nameserver
Recursive DNS with Unbound:
Device -> Pi-hole (Filter) -> Unbound localhost:5335 -> Root Nameservers -> TLD Nameservers -> Authoritative Server
By installing Unbound as a local recursive DNS resolver directly alongside Pi-hole inside a Proxmox VE LXC container, your homelab talks directly to the 13 global root DNS servers and authoritative name servers with DNSSEC validation. No upstream third party sees your network traffic.
Proxmox LXC Hardware Sizing & Specifications
An LXC (Linux Container) shares the host Linux kernel, eliminating the CPU virtualization overhead and idle power penalty of a full KVM virtual machine.
| Resource | Recommended Allocation | Real-World Utilization |
|---|---|---|
| Container OS | Debian 12 (Bookworm) Standard | Minimal footprint (~400MB disk) |
| vCPU Cores | 1 Core (Host type) | < 0.8% average CPU load |
| RAM | 512 MB (Swap: 512 MB) | ~115 MB to 135 MB active |
| Disk Storage | 8 GB NVMe / SSD | ~1.4 GB used (logs + query database) |
| Network | Static IPv4 + IPv6, Bridge vmbr0 |
Sub-millisecond local latency |
Step 1: Provisioning the Debian 12 LXC Container in Proxmox
You can create the container via the Proxmox Web GUI or quickly from the Proxmox VE shell:
# Download latest Debian 12 template (if not already downloaded)
pveam update
pveam download local debian-12-standard_12.7-1_amd64.tar.zst
# Create unprivileged LXC container (CT ID: 105)
pct create 105 local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst \
--hostname pihole-dns \
--cores 1 \
--memory 512 \
--swap 512 \
--ostype debian \
--storage local-lvm \
--rootfs volume=local-lvm:8 \
--net0 name=eth0,bridge=vmbr0,firewall=1,ip=192.168.1.5/24,gw=192.168.1.1 \
--nameserver 1.1.1.1 \
--onboot 1 \
--unprivileged 1
# Start container
pct start 105
pct enter 105
Pro-Tip: Setting
--onboot 1ensures your DNS container boots first whenever your mini PC restarts, preventing connection timeouts for dependent VMs and containers.
Step 2: Installing and Hardening Unbound
Inside the container console, update system packages and install unbound:
apt update && apt upgrade -y
apt install unbound curl sudo libcap2-bin -y
Download the Root Hints File
Unbound resolves queries by querying the root servers directly. Download the root hints file maintained by IANA:
curl -o /var/lib/unbound/root.hints https://www.internic.net/domain/named.root
Configure Unbound for Pi-hole
Create the optimized Pi-hole configuration file at /etc/unbound/unbound.conf.d/pi-hole.conf:
server:
verbosity: 1
interface: 127.0.0.1
port: 5335
do-ip4: yes
do-udp: yes
do-tcp: yes
do-ip6: no
prefer-ip6: no
# Use root hints
root-hints: "/var/lib/unbound/root.hints"
# Trust anchor file for DNSSEC validation
auto-trust-anchor-file: "/var/lib/unbound/root.key"
# Security settings
hide-identity: yes
hide-version: yes
harden-glue: yes
harden-dnssec-stripped: yes
use-caps-for-id: no
edns-buffer-size: 1232
prefetch: yes
num-threads: 1
# Ensure privacy of local subnets
private-address: 192.168.0.0/16
private-address: 172.16.0.0/12
private-address: 10.0.0.0/8
Restart and verify Unbound:
systemctl restart unbound
systemctl status unbound
# Test recursive query via localhost port 5335
dig pi-hole.net @127.0.0.1 -p 5335
You should see status: NOERROR and the flags: qr rd ra ad indicating full DNSSEC validation.
Step 3: Automated Pi-hole Installation
Run the official Pi-hole installation script:
curl -sSL https://install.pi-hole.net | bash
Follow the interactive prompts:
1. Network Interface: Select eth0.
2. Upstream DNS Provider: Select any default temporarily (e.g., Cloudflare); we will point to Unbound next.
3. Blocklist: Accept the default StevenBlack unified list (~180,000 domains).
4. Web Admin Interface: Select Enabled.
5. Web Server: Select Enabled (lighttpd).
6. Logging: Keep log queries enabled for auditing.
Set your admin web dashboard password:
pihole -a -p
Step 4: Connecting Pi-hole to Unbound
- Open your browser and navigate to
http://192.168.1.5/admin. - Log in and navigate to Settings → DNS.
- Under Upstream DNS Servers, uncheck all commercial providers (Google, Cloudflare, OpenDNS).
- In the Custom 1 (IPv4) box, enter:
127.0.0.1#5335 - Scroll down to Advanced DNS settings:
- Check Never forward non-FQDNs.
- Check Never forward reverse lookups for private IP ranges.
- Check Use DNSSEC (Unbound performs validation, but Pi-hole will display DNSSEC status in the Query Log).
- Click Save.
Step 5: Router DHCP Deployment & High Availability (HA)
To propagate Pi-hole across all home devices:
1. Log into your primary home router / gateway (e.g., OPNsense, UniFi, ASUS, or ISP box).
2. Go to LAN / DHCP Settings.
3. Set Primary DNS Server to 192.168.1.5 (your Pi-hole LXC IP).
4. Leave Secondary DNS blank (or point to a secondary Pi-hole node).
Warning: Do NOT put
1.1.1.1or8.8.8.8as Secondary DNS! Operating systems query secondary DNS servers concurrently, causing ad queries to leak and bypass your blocklists.
High Availability with Gravity Sync
If you run two Proxmox nodes or a backup Raspberry Pi, install Gravity Sync to automatically synchronize blocklists, local DNS records, and DHCP leases between primary and secondary instances:
export GS_INSTALL=primary
curl -sSL https://gravity-sync.com | bash
Benchmark Results: Cache Hits vs Latency
| Query Type | Typical Response Time | Notes |
|---|---|---|
| Local Cache Hit (Pi-hole FTL) | < 1 ms | Instant response from local RAM |
| Unbound Cached Hit | 1 - 3 ms | Served from Unbound local cache |
| First-time Recursive Resolution | 25 - 65 ms | Iterative traversal from root to authoritative nameserver |
| Commercial DNS (Cloudflare) | 12 - 20 ms | Faster cold hits, but centralized logging |
After 48 hours of normal browsing, your local cache hit ratio typically exceeds 60% to 75%, delivering faster resolution than remote public resolvers while preserving complete privacy.
Recommended Hardware for 24/7 DNS Hosting
A dedicated DNS resolver requires rock-solid 24/7 reliability and minimal power draw:
- TP-Link TL-SG108E 8-Port Gigabit Easy Smart Switch – Layer-2 managed switch for VLAN separation of IoT, guest, and management networks.
- Beelink EQ12 Intel N100 Mini PC – 6W idle host for Proxmox VE, running Pi-hole, Home Assistant, and TrueNAS alongside each other.
- APC UPS 600VA Battery Backup – Keep your home DNS, router, and fiber ONT alive during short utility power flickers.