[dnsdist] Disable cache for certain sources
Jacob Bunk Nielsen
jacob at bunknielsen.dk
Tue Apr 16 17:09:32 UTC 2024
Hi
Andreas Wili via dnsdist <dnsdist at mailman.powerdns.com> writes:
> I have dnsdist deployed centrally to route DNS queries to various backends:
> [...]
> In this setup, I use caching as follows:
> cache_all_queries = newPacketCache(2000000, {maxTTL=86400, minTTL=0,
> temporaryFailureTTL=60, staleTTL=60})
> getPool(""):setCache(cache_all_queries)
>
> I would now need to disable caching for certain servers that issue a DNS query. Is there a
> rule for this or any other option?
Do you mean that you do not want to cache responses from e.g.
"backend2"? Then you can try something like:
-- Configure backends in separate pools
newServer({
address='192.168.100.10',
name='backend1',
pool='use_cache_pool'
})
newServer({
address='192.168.100.20',
name='backend2',
pool='no_cache_pool'
})
-- Create cache
cache_all_queries = newPacketCache(2000000,
{maxTTL=86400,
minTTL=0,
temporaryFailureTTL=60,
staleTTL=60})
-- Set cache for the "use_cache_pool"
getPool('use_cache_pool'):setCache(cache_all_queries)
-- route requests to your two pools, this will route ~50% to the pool
-- using cache and the remaining queries to your no_cache_pool.
-- You probably want something else, but I can't guess what.
AddAction(ProbaRule(0.5), PoolAction('use_cache_pool'))
AddAction(AllRule(), PoolAction('no_cache_pool'))
If it's something else you wish to achieve, then please describe in more
words, e.g. with an example.
Best regards,
Jacob
More information about the dnsdist
mailing list