<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: NXVL</title>
    <description>The latest articles on DEV Community by NXVL (@manpage).</description>
    <link>https://dev.to/manpage</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4198975%2F65dc52c8-8434-4743-b6dc-f065431dd023.png</url>
      <title>DEV Community: NXVL</title>
      <link>https://dev.to/manpage</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/manpage"/>
    <language>en</language>
    <item>
      <title>Pi-hole with Unbound: Private Recursive DNS Explained</title>
      <dc:creator>NXVL</dc:creator>
      <pubDate>Wed, 21 Oct 2026 19:15:00 +0000</pubDate>
      <link>https://dev.to/manpage/pi-hole-with-unbound-private-recursive-dns-explained-46m5</link>
      <guid>https://dev.to/manpage/pi-hole-with-unbound-private-recursive-dns-explained-46m5</guid>
      <description>&lt;p&gt;Most "private DNS" setups only move your trust around. You stop asking your ISP and start asking Google, Cloudflare, or Quad9 instead. Pi-hole with Unbound goes a step further: &lt;strong&gt;block unwanted domains first, then resolve everything else yourself&lt;/strong&gt;, with no public resolver in the middle.&lt;/p&gt;

&lt;p&gt;This guide explains how the two pieces fit together, how to build the setup on your own server, and what it does and does not protect.&lt;/p&gt;

&lt;h2&gt;
  
  
  The two pieces
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Pi-hole&lt;/strong&gt; is a DNS filter. Your devices ask it for a domain name, and it checks the request against your blocklists. If the domain is an ad network, tracker, or telemetry endpoint, Pi-hole answers with "nothing here" and the connection never starts. It also keeps a query log, so you can see which device asked for what.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Unbound&lt;/strong&gt; is a &lt;em&gt;recursive&lt;/em&gt; DNS resolver. A normal setup forwards your questions to a big public resolver that does the work for you. Unbound does the work itself: it starts at the DNS root servers, follows the chain to the &lt;code&gt;.com&lt;/code&gt; servers, then to the domain's own authoritative servers, and caches the answer. It also validates &lt;strong&gt;DNSSEC&lt;/strong&gt; signatures, so forged answers are rejected.&lt;/p&gt;

&lt;p&gt;Put together, the flow looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Your device
   │  (DoT / DoH, encrypted)
   ▼
Pi-hole        → blocked? answer immediately, nothing leaves the server
   │  (allowed)
   ▼
Unbound        → recursive lookup + DNSSEC validation + cache
   │
   ▼
Root → TLD → authoritative servers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why not just forward to Cloudflare or Quad9?
&lt;/h2&gt;

&lt;p&gt;Forwarding is fast and simple, and for many people it is a fine choice. The trade-off is that one company sees the full list of domains you look up, from every device, tied to your IP address.&lt;/p&gt;

&lt;p&gt;With Unbound as the upstream:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No single resolver sees your whole history.&lt;/strong&gt; Each authoritative server only sees the question it is responsible for, such as "what is the address of &lt;code&gt;example.com&lt;/code&gt;?".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You do not depend on a third party's uptime or policy.&lt;/strong&gt; Nobody can change filtering or logging rules underneath you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DNSSEC is checked on your own server&lt;/strong&gt;, not trusted from someone else's answer.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Option A: Build it yourself
&lt;/h2&gt;

&lt;p&gt;These steps assume a small Debian or Ubuntu server with Pi-hole already installed.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Install Unbound
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;unbound
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Configure it to listen only on localhost
&lt;/h3&gt;

&lt;p&gt;Create &lt;code&gt;/etc/unbound/unbound.conf.d/pi-hole.conf&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;server&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;verbosity&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;

    &lt;span class="na"&gt;interface&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;127.0.0.1&lt;/span&gt;
    &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5335&lt;/span&gt;
    &lt;span class="na"&gt;do-ip4&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;yes&lt;/span&gt;
    &lt;span class="na"&gt;do-udp&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;yes&lt;/span&gt;
    &lt;span class="na"&gt;do-tcp&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;yes&lt;/span&gt;
    &lt;span class="na"&gt;do-ip6&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;no&lt;/span&gt;

    &lt;span class="na"&gt;harden-glue&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;yes&lt;/span&gt;
    &lt;span class="na"&gt;harden-dnssec-stripped&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;yes&lt;/span&gt;
    &lt;span class="na"&gt;use-caps-for-id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;no&lt;/span&gt;
    &lt;span class="na"&gt;edns-buffer-size&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1232&lt;/span&gt;

    &lt;span class="na"&gt;prefetch&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;yes&lt;/span&gt;
    &lt;span class="na"&gt;num-threads&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;

    &lt;span class="na"&gt;private-address&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;192.168.0.0/16&lt;/span&gt;
    &lt;span class="na"&gt;private-address&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;172.16.0.0/12&lt;/span&gt;
    &lt;span class="na"&gt;private-address&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;10.0.0.0/8&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Port &lt;code&gt;5335&lt;/code&gt; keeps Unbound out of Pi-hole's way on port 53. Binding to &lt;code&gt;127.0.0.1&lt;/code&gt; means nothing outside the server can talk to it directly. The &lt;code&gt;private-address&lt;/code&gt; lines stop Unbound from returning answers that point into your private network, which helps against DNS rebinding.&lt;/p&gt;

&lt;p&gt;Restart it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl restart unbound
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Test Unbound on its own
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig example.com @127.0.0.1 &lt;span class="nt"&gt;-p&lt;/span&gt; 5335
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should get an answer with &lt;code&gt;status: NOERROR&lt;/code&gt;. Now check that DNSSEC validation works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig sigfail.verteiltesysteme.net @127.0.0.1 &lt;span class="nt"&gt;-p&lt;/span&gt; 5335
dig sigok.verteiltesysteme.net @127.0.0.1 &lt;span class="nt"&gt;-p&lt;/span&gt; 5335
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first must return &lt;code&gt;SERVFAIL&lt;/code&gt; (a deliberately broken signature, correctly rejected). The second must return &lt;code&gt;NOERROR&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Point Pi-hole at Unbound
&lt;/h3&gt;

&lt;p&gt;In the Pi-hole web interface:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;Settings → DNS&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Untick every public upstream (Google, Cloudflare, and so on).&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;Custom DNS servers&lt;/strong&gt;, add &lt;code&gt;127.0.0.1#5335&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Save.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;From now on, anything Pi-hole allows is resolved by Unbound.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Encrypt the path from your devices
&lt;/h3&gt;

&lt;p&gt;Plain DNS between your phone and your server is readable by anyone on the network path. To fix that, expose your Pi-hole over &lt;strong&gt;DoT&lt;/strong&gt; (port 853) or &lt;strong&gt;DoH&lt;/strong&gt; (port 443) using a TLS-terminating proxy in front of it, such as stunnel, nginx, or dnsdist, with a valid certificate for a hostname you own. Then use that hostname in Android's &lt;strong&gt;Private DNS&lt;/strong&gt; setting or the equivalent on iOS and macOS.&lt;/p&gt;

&lt;p&gt;Expect to spend most of your time on this step: certificates, renewals, firewall rules, and keeping the proxy updated.&lt;/p&gt;

&lt;h2&gt;
  
  
  Option B: Let a managed node do it
&lt;/h2&gt;

&lt;p&gt;If you want the same architecture without the maintenance, NxValue Stack provisions a &lt;strong&gt;private Pi-hole + Unbound node&lt;/strong&gt; for you. It is not a shared public resolver: it is your own isolated server running open-source Pi-hole and Unbound, configured for you alone.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unbound runs as a DNSSEC-validating recursive resolver on your node.&lt;/li&gt;
&lt;li&gt;DoH and DoT endpoints are generated for you, so you paste one hostname into Private DNS and you are done.&lt;/li&gt;
&lt;li&gt;The dashboard shows live queries and blocked domains per device, and you can export or delete your data at any time.&lt;/li&gt;
&lt;li&gt;Billing is hourly and you can cancel anytime. The BASE-N plan is &lt;strong&gt;$4/month&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can try the &lt;a href="//nxvalue.com/test/v1/"&gt;demo node here&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Some limits to this setup
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Encrypted DNS stops your ISP and local network from reading your DNS lookups, but they can still see the IP addresses you connect to&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The first lookup of a domain can be slower.Recursion has to walk the chain of servers. Caching and &lt;code&gt;prefetch&lt;/code&gt; hide most of this after a short warm-up.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Authoritative servers still see your server's IP. They just cannot see a complete profile of you the way a single big well-known forwarder like Google/CF would.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;DNS blocking is not a full ad blocker.&lt;/strong&gt; First-party ads, such as video ads on YouTube or Twitch, come from the same domains as the content and cannot be separated at the DNS level. Pair Pi-hole with a browser content blocker for full coverage.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pi-hole&lt;/strong&gt; decides &lt;em&gt;what&lt;/em&gt; gets resolved. &lt;strong&gt;Unbound&lt;/strong&gt; decides &lt;em&gt;how&lt;/em&gt;, without a public resolver.&lt;/li&gt;
&lt;li&gt;Self-hosting gives you full control, at the cost of setting up TLS, certificates, and maintenance.&lt;/li&gt;
&lt;li&gt;A managed private node gives you the same stack with encrypted endpoints ready in about a minute.&lt;/li&gt;
&lt;li&gt;Either way, the result is DNS that blocks trackers, validates DNSSEC, and does not funnel your history into one large resolver.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Pi-hole is a registered trademark of Pi-hole LLC. NxValue Stack is an independent service provider and is not affiliated with Pi-hole LLC.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>opensource</category>
      <category>showdev</category>
      <category>saas</category>
    </item>
  </channel>
</rss>
