<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[recursive dns - fe84]]></title><description><![CDATA[> notes to self _]]></description><link>https://blog.foureight84.com/</link><image><url>https://blog.foureight84.com/favicon.png</url><title>recursive dns - fe84</title><link>https://blog.foureight84.com/</link></image><generator>Ghost 4.8</generator><lastBuildDate>Sat, 11 Apr 2026 19:53:52 GMT</lastBuildDate><atom:link href="https://blog.foureight84.com/tag/recursive-dns/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Pi-Hole Recursive DNS with Unbound]]></title><description><![CDATA[Deploying Unbound recursive DNS server locally with Pi-Hole using Docker]]></description><link>https://blog.foureight84.com/pi-hole-recursive-dns/</link><guid isPermaLink="false">61bb93cf0a679a00014c664d</guid><category><![CDATA[adblocking]]></category><category><![CDATA[pihole]]></category><category><![CDATA[unbound]]></category><category><![CDATA[recursive dns]]></category><category><![CDATA[cloudflare]]></category><category><![CDATA[swarm]]></category><category><![CDATA[traefik]]></category><dc:creator><![CDATA[foureight84]]></dc:creator><pubDate>Thu, 16 Dec 2021 20:42:08 GMT</pubDate><media:content url="https://blog.foureight84.com/content/images/2021/12/Unbound_FC_Shaded_cropped.svg" medium="image"/><content:encoded><![CDATA[<img src="https://blog.foureight84.com/content/images/2021/12/Unbound_FC_Shaded_cropped.svg" alt="Pi-Hole Recursive DNS with Unbound"><p>In the previous post, I wrote an extensive guide on <a href="https://blog.foureight84.com/swarm-your-pihole">deploying Cloudflare as the upstream DNS for Pi-Hole over HTTPS</a>. This is a follow-up where Cloudflare is replaced with <a href="https://www.nlnetlabs.nl/projects/unbound/about/">Unbound</a> as the upstream DNS server. </p><p>Unbound is a recursive DNS that sits between Pi-Hole and authoritative DNS servers. Cloudflare&apos;s 1.1.1.1 and Google&apos;s 8.8.8.8 are examples of recursive DNS services. By making Unbound the upstream DNS server for Pi-Hole, you&apos;re cutting out other third parties from tracking your web presence. A more detailed read-up of this setup can be found on the official <a href="https://docs.pi-hole.net/guides/dns/unbound/">Pi-Hole Unbound guide</a>.</p><p>Back on June 11, 2021, Cloudflare DNS experienced outages in the Los Angeles and Chicago area. The result was over an hour of downtime with its DNS service. I was able to avoid that outage by switching over to Unbound and letting it handle domain resolution directly with authoritative DNS servers. This method can be a little slow but DNS caching in Pi-Hole becomes beneficial on subsequent lookups.</p><h2 id="deploying-unbound-with-pi-hole">Deploying Unbound with Pi-Hole</h2><p>In the previous post, Pi-Hole and Cloudflare DNS were deployed using Docker Swarm and managed through Portainer with Traefik as the reverse proxy. This will follow the previous guide closely. Let&apos;s start by cloning the project:</p><pre><code class="language-bash">git clone https://github.com/foureight84/traefik-pihole-doh.git &amp;&amp; cd traefik-pihole-doh</code></pre><p>This guide assumes that your Docker Swarm, Portainer, and Traefik have been properly configured. If not, <a href="https://blog.foureight84.com/swarm-your-pihole/#getting-started">follow this guide</a>.</p><p>Go to your Portainer web portal and click on App Templates -&gt; Custom Templates and click on the &quot;+ Add Custom Template&quot; button.</p><!--kg-card-begin: markdown--><blockquote>
<p>This stack uses Unbound Docker image created by Kyle Harding (<a href="https://github.com/klutchell">https://github.com/klutchell</a>)<br>
Image: <a href="https://hub.docker.com/r/klutchell/unbound">https://hub.docker.com/r/klutchell/unbound</a><br>
Github: <a href="https://github.com/klutchell/unbound-docker">https://github.com/klutchell/unbound-docker</a></p>
</blockquote>
<!--kg-card-end: markdown--><p>You&apos;ll need to fill in a relevant title for the template. I called mine <code>recursive_dns</code>. Add a description - <code>Pi-hole and Unbound</code>. Make sure the template Type is set to <code>Swarm</code>. Then click on the Upload option and choose the <code>docker-compose.yaml</code> in the <code>dns-unbound</code> folder in the cloned project.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://blog.foureight84.com/content/images/2021/12/Pi-hole-Unbound-Portainer.PNG" class="kg-image" alt="Pi-Hole Recursive DNS with Unbound" loading="lazy" width="1406" height="1002" srcset="https://blog.foureight84.com/content/images/size/w600/2021/12/Pi-hole-Unbound-Portainer.PNG 600w, https://blog.foureight84.com/content/images/size/w1000/2021/12/Pi-hole-Unbound-Portainer.PNG 1000w, https://blog.foureight84.com/content/images/2021/12/Pi-hole-Unbound-Portainer.PNG 1406w" sizes="(min-width: 720px) 720px"><figcaption>Uploading dns-unbound/docker-compose.yaml as a Swarm template</figcaption></figure><!--kg-card-begin: markdown--><p><s>After it has been uploaded, find the newly created custom template in the list of templates and click edit.<br>
We will need to check that <code>PIHOLE_DNS_=172.18.0.1#5053</code> environment variable matches your <code>docker_gwbridge</code> IPV4 IPAM Gateway address. Once verified, deploy the stack. That&apos;s it!</s></p>
<p>Deploy the stack once the custom template has been uploaded. The <code>klutchell/unbound</code> Docker image now listens on port 53 by default. Setting the <code>PIHOLE_DNS</code> environment variable to the <code>unbound</code> service name is all that&apos;s needed.</p>
<!--kg-card-end: markdown--><!--kg-card-begin: html--><aside class="note">Make sure you&apos;re only running one instance of Pi-Hole. If you are running Pi-Hole with Cloudflare from the previous guide, be sure to remove that stack before deploying this stack.</aside><!--kg-card-end: html--><p>While uncached DNS queries may be slower than using Google&apos;s public DNS (8.8.8.8) we can see that Pi-Hole&apos;s caching outpaces all other public DNS services by far. Plus the millisecond differences in uncached queries are not noticeable in a real use case scenario. It&apos;s actually faster than using Cloudflare!</p><figure class="kg-card kg-image-card"><img src="https://blog.foureight84.com/content/images/2021/12/image.png" class="kg-image" alt="Pi-Hole Recursive DNS with Unbound" loading="lazy" width="596" height="928"></figure><pre><code>  192.168.  1.  4 |  Min  |  Avg  |  Max  |Std.Dev|Reliab%|
  ----------------+-------+-------+-------+-------+-------+
  + Cached Name   | 0.000 | 0.001 | 0.001 | 0.000 | 100.0 |
  + Uncached Name | 0.015 | 0.060 | 0.187 | 0.052 | 100.0 |
  + DotCom Lookup | 0.015 | 0.049 | 0.081 | 0.022 | 100.0 |
  ---&lt;O-OO----&gt;---+-------+-------+-------+-------+-------+
                     pihole.home
                Local Network Nameserver


    1.  1.  1.  1 |  Min  |  Avg  |  Max  |Std.Dev|Reliab%|
  ----------------+-------+-------+-------+-------+-------+
  - Cached Name   | 0.012 | 0.013 | 0.018 | 0.001 | 100.0 |
  - Uncached Name | 0.014 | 0.069 | 0.355 | 0.077 | 100.0 |
  - DotCom Lookup | 0.014 | 0.022 | 0.048 | 0.009 | 100.0 |
  ---&lt;--------&gt;---+-------+-------+-------+-------+-------+
                     one.one.one.one
                    CLOUDFLARENET, US
                    
    8.  8.  8.  8 |  Min  |  Avg  |  Max  |Std.Dev|Reliab%|
  ----------------+-------+-------+-------+-------+-------+
  - Cached Name   | 0.012 | 0.015 | 0.023 | 0.002 | 100.0 |
  - Uncached Name | 0.014 | 0.038 | 0.158 | 0.040 | 100.0 |
  - DotCom Lookup | 0.014 | 0.016 | 0.025 | 0.002 | 100.0 |
  ---&lt;--------&gt;---+-------+-------+-------+-------+-------+
                       dns.google
                       GOOGLE, US</code></pre>]]></content:encoded></item></channel></rss>