[Pdns-users] Disable pdns-recursor caching for a single forwarded domain

Peter van Dijk peter.van.dijk at powerdns.com
Fri Jul 21 08:51:56 UTC 2017

Hello Ken,

On 20 Jul 2017, at 16:37, Kenneth Marshall wrote:

> I am currently running pdns-recursor version 3.7.4 and am trying to
> disable caching for a single forwarded domain. I am current trying
> to use the following lua script but although being called, the
> setvariable() call does not seem to turn off the caching. I would
> expect each call to hit the DNS servers for the forwarded zone:
> ------------------nocache.lua
> function endswith(s, send)
>          return #s >= #send and s:find(send, #s-#send+1, true) and 
> true or false
> end
> function preresolve( remoteip, domain, qtype )
>   if endswith(domain, ".ad.rice.edu.")
>   then
>     if qtype ~= pdns.A
>     then
>       return pdns.PASS, {}
>     end
>     pdnslog("preresolve called for: "..domain, pdns.loglevels.Info)
>     setvariable()
>   end
>   return pdns.PASS, {}
> end
> ------------------nocache.lua
> Is this possible? I have tried the same with a postresolve() function
> but it still appears to cache based on the TTL.

setvariable() and anything you do to TTLs will only affect the packet 
cache, not the cache for responses from other servers.

Is this a forward or a forward-recurse? If the latter, you could do this 
in dnsdist. If the former, you could do this with dnsdist and an 
-additional- recursor.

Kind regards,
Peter van Dijk
PowerDNS.COM BV - https://www.powerdns.com/

More information about the Pdns-users mailing list