<?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"><channel><title><![CDATA[Caching of NXDOMAIN]]></title><description><![CDATA[<p dir="auto">In my dns log and in the pfBlocker reports I'm getting a lot of reverse resolves from mainly 77.90.x.x, but also other IPs that results in a NXDOMAIN. The log says they have a TTL of 3600 sec (might be because I configured that as the minimum TTL), but the resolver responds every time even if just a couple of seconds has passed since the last resolve. How do I get the dns resolver to cache these responses and not do a new lookup every time?</p>
]]></description><link>https://forum.netgate.com/topic/184521/caching-of-nxdomain</link><generator>RSS for Node</generator><lastBuildDate>Fri, 12 Jun 2026 17:44:06 GMT</lastBuildDate><atom:link href="https://forum.netgate.com/topic/184521.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 02 Dec 2023 11:08:56 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Caching of NXDOMAIN on Sun, 03 Dec 2023 12:20:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jesper-1">@<bdi>Jesper-1</bdi></a> said in <a href="/post/1139874">Caching of NXDOMAIN</a>:</p>
<blockquote>
<p dir="auto">When I compare that to the GUI-Top Reply DST IP it says 71% is NXDOMAIN</p>
</blockquote>
<p dir="auto">A break down of what answers were found for what is asked has little to do with that answer was actually resolved or from cache.</p>
<p dir="auto">You could have 0 or 100% cache hits. That really wouldn't have anything to do with they all had answers or all were NX.</p>
<p dir="auto">The info there like you provided direct from unbound, is the info you would want to look at to know how much was answered from cache by unbound, and how much was not.</p>
<p dir="auto">How to interpret what pfblocker might be saying I am not sure - I don't use pfblocker to block any dns, I use it to create aliases that I use in my rules.  Sorry.   Unbound is the resolver - to know your cache hit or miss rate, you should look to the stats directly from unbound.</p>
<p dir="auto">Keep mind any sort of stats on NX can be skewed, depending even in your settings to response.  For example I block some stuff directly in unbound to respond with NX. Even if said thing might resolve to something, unbound returns NX.</p>
]]></description><link>https://forum.netgate.com/post/1139889</link><guid isPermaLink="true">https://forum.netgate.com/post/1139889</guid><dc:creator><![CDATA[johnpoz]]></dc:creator><pubDate>Sun, 03 Dec 2023 12:20:17 GMT</pubDate></item><item><title><![CDATA[Reply to Caching of NXDOMAIN on Sun, 03 Dec 2023 09:15:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/johnpoz">@<bdi>johnpoz</bdi></a></p>
<p dir="auto">The server is not restarting (even if I restarted it manually recently to change settings).</p>
<p dir="auto">I think it is actually the pfBlocker GUI that is showing wrong.</p>
<p dir="auto">Because when I look in the GUI-Top Reply Type it says 22% cache and 75% from the resolver<br />
When I compare that to the GUI-Top Reply DST IP it says 71% is NXDOMAIN</p>
<p dir="auto">So I just assumed these were not cached because when I went into the Reports - DNS reply all these NXDOMAIN replies were from the resolver and not from the cache. Like I said before, if I did a dig command from a VM manually for the same IPs, those logs showed cache.</p>
<p dir="auto">Though if I run the command:<br />
unbound-control -c /var/unbound/unbound.conf stats_noreset | grep total.num</p>
<p dir="auto">I actually get a very high cache rate. (79%)</p>
<p dir="auto">total.num.queries=26750<br />
total.num.queries_ip_ratelimited=0<br />
total.num.queries_cookie_valid=0<br />
total.num.queries_cookie_client=0<br />
total.num.queries_cookie_invalid=0<br />
total.num.cachehits=21199<br />
total.num.cachemiss=5551<br />
total.num.prefetch=3823<br />
total.num.queries_timed_out=0<br />
total.num.expired=2430</p>
]]></description><link>https://forum.netgate.com/post/1139874</link><guid isPermaLink="true">https://forum.netgate.com/post/1139874</guid><dc:creator><![CDATA[Jesper 1]]></dc:creator><pubDate>Sun, 03 Dec 2023 09:15:40 GMT</pubDate></item><item><title><![CDATA[Reply to Caching of NXDOMAIN on Sat, 02 Dec 2023 21:05:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jesper-1">@<bdi>Jesper-1</bdi></a> said in <a href="/post/1139818">Caching of NXDOMAIN</a>:</p>
<blockquote>
<p dir="auto">What I'm asking is why nothing gets cached?</p>
</blockquote>
<p dir="auto">where are you seeing its not cached?  Because there was a log that something asked for something?</p>
<p dir="auto">Unbound is going to cache the answer it gets.. You can adjust the min cache so it stores it longer, but its going to cache answers it gets to things it asked for.. You could set NX to cache for like 1 second if you wanted to via the option I posted above.. But that is not exposed in the gui.</p>
<p dir="auto">You sure your unbound isn't just constantly restarting - dhcp registration can do that, and that will flush the cache.. If your only seeing like 20% hit ratio, that could maybe account for such a low hit rate..</p>
<p dir="auto">You can look in your cache directly if you want via</p>
<p dir="auto">unbound-control -c /var/unbound/unbound.conf dump_cache</p>
<p dir="auto">I just very recently restarted unbound.. but a look at the stats_noreset</p>
<pre><code>total.num.queries=1855
total.num.queries_ip_ratelimited=0
total.num.queries_cookie_valid=0
total.num.queries_cookie_client=0
total.num.queries_cookie_invalid=0
total.num.cachehits=1480
</code></pre>
<p dir="auto">So from that, cache was hit 1480 out of 1855 or what 79 something percent.</p>
<p dir="auto">What exactly is not getting cached.. if you query unbound for something.. and then you ask it again your saying the ttl is not going down.. That indicates it served you from cache, also as in above if your first query for something is like 100ms and then your next query is only 2 ms - that was served from cache and not resolved..</p>
]]></description><link>https://forum.netgate.com/post/1139829</link><guid isPermaLink="true">https://forum.netgate.com/post/1139829</guid><dc:creator><![CDATA[johnpoz]]></dc:creator><pubDate>Sat, 02 Dec 2023 21:05:16 GMT</pubDate></item><item><title><![CDATA[Reply to Caching of NXDOMAIN on Sat, 02 Dec 2023 20:16:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/johnpoz">@<bdi>johnpoz</bdi></a><br />
What I'm asking is why nothing gets cached? All these replies are resolver replies. If I do a dig manually, it caches, but all these replies does not get cached. How do I make the dns to cache them?</p>
<p dir="auto">I'm looking in the pfBlocker reports section, and also in the dns_reply.log</p>
]]></description><link>https://forum.netgate.com/post/1139818</link><guid isPermaLink="true">https://forum.netgate.com/post/1139818</guid><dc:creator><![CDATA[Jesper 1]]></dc:creator><pubDate>Sat, 02 Dec 2023 20:16:03 GMT</pubDate></item><item><title><![CDATA[Reply to Caching of NXDOMAIN on Sat, 02 Dec 2023 17:08:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jesper-1">@<bdi>Jesper-1</bdi></a> said in <a href="/post/1139788">Caching of NXDOMAIN</a>:</p>
<blockquote>
<p dir="auto">router. resolver PTR PTR 185.185.90.77.in-addr.arpa 17015... NXDOMAIN unk<br />
Dec 2 16:10:21 127.0.0.1<br />
router.&lt;mydomain&gt; resolver PTR PTR 185.185.90.77.in-addr.arpa 3600 NXDOMAIN unk</p>
</blockquote>
<p dir="auto">So are you asking why some have 3600 and some have that 17015?  Which is also cached..</p>
<pre><code>;; AUTHORITY SECTION:
77.in-addr.arpa.        3600    IN      SOA     pri.authdns.ripe.net. dns.ripe.net. 1701527412 3600 600 864000 3600
</code></pre>
<p dir="auto">that 17015... looks to be the Serial number and your just not seeing it all in whatever your looking at, see the ... there.  As you can see from the full SOA I posted for that IP.. the min ttl is set at 3600 per the SOA.. So be it your min setting or pulling it from the SOA record.</p>
<blockquote>
<p dir="auto">but for the ones from the dns resolver itself, it doesn't cache</p>
</blockquote>
<p dir="auto">Not sure what your asking there.. and not really sure where your looking at those logs?  A resolver is not going to ask for random IP PTRs - a resolver would only try to resolve after some client asked it..  It would hand the client that asked it the TTL..  be it an actual client, or some NS that is forwarding to your resolver.</p>
<p dir="auto">The client not adhering to the TTL is up to the client..</p>
]]></description><link>https://forum.netgate.com/post/1139792</link><guid isPermaLink="true">https://forum.netgate.com/post/1139792</guid><dc:creator><![CDATA[johnpoz]]></dc:creator><pubDate>Sat, 02 Dec 2023 17:08:44 GMT</pubDate></item><item><title><![CDATA[Reply to Caching of NXDOMAIN on Sat, 02 Dec 2023 16:32:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/johnpoz">@<bdi>johnpoz</bdi></a></p>
<p dir="auto">Thanks for your extensive reply.</p>
<p dir="auto">Yes, so I have a lot of logs from reverse resolves done by the dns server itself. I'm not exactly sure where they are coming from. My guess is from some of the blocklists in pfBlocker. When I view the logs from them it looks like this (pasted from the DNS Reply section of pfBlocker). Some of them are with the 3600 TTL and some with a super long TTL</p>
<p dir="auto">Dec 2 16:18:52  127.0.0.1<br />
router.&lt;mydomain&gt;  resolver  PTR PTR   185.185.90.77.in-addr.arpa  17015...  NXDOMAIN  unk<br />
Dec 2 16:16:36  127.0.0.1<br />
router.  resolver  PTR PTR   185.185.90.77.in-addr.arpa  17015...  NXDOMAIN  unk<br />
Dec 2 16:10:21  127.0.0.1<br />
router.&lt;mydomain&gt;  resolver  PTR PTR   185.185.90.77.in-addr.arpa  3600  NXDOMAIN  unk<br />
Dec 2 16:10:21  127.0.0.1<br />
router.&lt;mydomain&gt;  resolver  PTR PTR   185.185.90.77.in-addr.arpa  17015...  NXDOMAIN  unk<br />
Dec 2 15:58:13  127.0.0.1<br />
router.&lt;mydomain&gt;  resolver  PTR PTR   185.185.90.77.in-addr.arpa  17015...  NXDOMAIN  unk</p>
<p dir="auto">But if I do like you did, and run a: "dig -x 185.185.90.77.in-addr.arpa @192.168.6.1" from an Ubuntu VM on the same network it works, and it caches the data: Same behavior here, some with 3600 TTL and some with a really long TTL</p>
<p dir="auto">Dec 2 17:07:57  192.168.6.20<br />
&lt;ubuntu-client&gt;  cache PTR PTR   arpa.in-addr.77.90.185.185.in-addr.arpa 3596  NXDOMAIN  unk<br />
Dec 2 17:07:56  127.0.0.1<br />
router.&lt;mydomain&gt;  resolver  PTR PTR   71.185.90.77.in-addr.arpa 17015...  NXDOMAIN  unk<br />
Dec 2 17:07:55  192.168.6.20<br />
&lt;ubuntu-client&gt;  cache PTR PTR   arpa.in-addr.77.90.185.185.in-addr.arpa 3598  NXDOMAIN  unk<br />
Dec 2 17:07:53  192.168.6.20<br />
&lt;ubuntu-client&gt;  reply PTR PTR   arpa.in-addr.77.90.185.185.in-addr.arpa 3600  NXDOMAIN  unk</p>
<p dir="auto">It seems like it works and does caching when I question manually, but for the ones from the dns resolver itself, it doesn't cache, it just keeps resolving all the time over and over again. Because of this I only get about 20% cache ratio.</p>
]]></description><link>https://forum.netgate.com/post/1139788</link><guid isPermaLink="true">https://forum.netgate.com/post/1139788</guid><dc:creator><![CDATA[Jesper 1]]></dc:creator><pubDate>Sat, 02 Dec 2023 16:32:30 GMT</pubDate></item><item><title><![CDATA[Reply to Caching of NXDOMAIN on Sat, 02 Dec 2023 11:51:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jesper-1">@<bdi>Jesper-1</bdi></a> not sure what your asking - why wouldn't the resolver answer the client because it was NX?</p>
<p dir="auto">The neg should be cached, for the length sent by the SOA, or whatever your min ttl was set to.. Or if you had set a</p>
<p dir="auto">cache-max-negative-ttl</p>
<p dir="auto">Value, don't believe that parameter is exposed to the gui. But you could always set it in the custom options.</p>
<p dir="auto">But if I query for example www.lgsjldjhlsjfsfd.com the SOA for .com would respond NX..</p>
<pre><code> &lt;&lt;&gt;&gt; DiG 9.16.45 &lt;&lt;&gt;&gt; @192.168.9.253 www.lsjdlsdjfs.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NXDOMAIN, id: 18839
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.lsjdlsdjfs.com.            IN      A

;; AUTHORITY SECTION:
com.                    3600    IN      SOA     a.gtld-servers.net. nstld.verisign-grs.com. 1701515704 1800 900 604800 86400

;; Query time: 13 msec
;; SERVER: 192.168.9.253#53(192.168.9.253)
;; WHEN: Sat Dec 02 05:15:29 Central Standard Time 2023
;; MSG SIZE  rcvd: 120
</code></pre>
<p dir="auto">From that response there would be a min ttl, but you overrode it with yours..  This min ttl would be the min ttl for records under the soa that don't have their own specific ttl set.  Or would be used as the neg ttl, ie how long to cache a NX..</p>
<p dir="auto">That NX response would be cached, and if a client asks again - then that NX would be served by the cache..  Are you saying that unbound constantly tries to resolve it, and its not being served by the cache?</p>
<p dir="auto">So for example in the above see how ttl returned is 3600 (I too have min ttl set to 3600) but if I ask it a little bit later notice the ttl has gone down, and notice the query time is only 2 ms, ie it was served to me (the client) from cache.</p>
<pre><code>; &lt;&lt;&gt;&gt; DiG 9.16.45 &lt;&lt;&gt;&gt; @192.168.9.253 www.lsjdlsdjfs.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NXDOMAIN, id: 24497
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.lsjdlsdjfs.com.            IN      A

;; AUTHORITY SECTION:
com.                    2872    IN      SOA     a.gtld-servers.net. nstld.verisign-grs.com. 1701515704 1800 900 604800 86400

;; Query time: 2 msec
;; SERVER: 192.168.9.253#53(192.168.9.253)
;; WHEN: Sat Dec 02 05:27:37 Central Standard Time 2023
;; MSG SIZE  rcvd: 120
</code></pre>
<p dir="auto">If you have a client that keeps asking for something, unbound will answer and log it, etc. even that answer is a NX, etc. When you have a client that does not have a local cache, you can see it bombing your NS over and over again - even if the response was NX.. You see this a lot in iot devices, and such that do not run a local cache.. But with any request be it got an IP or NX, the client shouldn't ask the NS again until the TTL the NS responded with expires.. But this not the case for many a client.. So yeah your NS logs can be filled with constant asks..</p>
<p dir="auto">Queries for PTRs quite often have not been set by the owners, so yeah if something really wants the PTR for some IP, and it doesn't exist - if it keeps asking, unbound will keep answering - even if that answer is NX.</p>
<p dir="auto">example of a PTR.. so this is NX</p>
<pre><code>; &lt;&lt;&gt;&gt; DiG 9.16.45 &lt;&lt;&gt;&gt; -x 1.2.3.4 @192.168.9.253
;; global options: +cmd
;; Got answer:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NXDOMAIN, id: 64130
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;4.3.2.1.in-addr.arpa.          IN      PTR

;; AUTHORITY SECTION:
1.in-addr.arpa.         3600    IN      SOA     ns.apnic.net. read-txt-record-of-zone-first-dns-admin.apnic.net. 21462 7200 1800 604800 3600

;; Query time: 319 msec
;; SERVER: 192.168.9.253#53(192.168.9.253)
;; WHEN: Sat Dec 02 05:45:38 Central Standard Time 2023
;; MSG SIZE  rcvd: 137
</code></pre>
<p dir="auto">If I ask again.. Sure unbound answered, but look at the query time = 1 ms, it answered from its cache. And you will notice the ttl counting down.. When you get an odd ball sort of ttl, and not specific setting be it 60, or 300, or 3600 or even 1 day, etc. This is telling you it was pulled from a cache, and not from an authoritative NS..  Be it your NS cache, or the case when you forward, where you forwarded cache.</p>
<pre><code>; &lt;&lt;&gt;&gt; DiG 9.16.45 &lt;&lt;&gt;&gt; -x 1.2.3.4 @192.168.9.253
;; global options: +cmd
;; Got answer:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NXDOMAIN, id: 4794
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;4.3.2.1.in-addr.arpa.          IN      PTR

;; AUTHORITY SECTION:
1.in-addr.arpa.         3594    IN      SOA     ns.apnic.net. read-txt-record-of-zone-first-dns-admin.apnic.net. 21462 7200 1800 604800 3600

;; Query time: 1 msec
;; SERVER: 192.168.9.253#53(192.168.9.253)
;; WHEN: Sat Dec 02 05:45:44 Central Standard Time 2023
;; MSG SIZE  rcvd: 137
</code></pre>
]]></description><link>https://forum.netgate.com/post/1139739</link><guid isPermaLink="true">https://forum.netgate.com/post/1139739</guid><dc:creator><![CDATA[johnpoz]]></dc:creator><pubDate>Sat, 02 Dec 2023 11:51:00 GMT</pubDate></item></channel></rss>