Pdns: Dump Cached DNS requests

Created on 27 Oct 2016  路  6Comments  路  Source: PowerDNS/pdns

Firstly apologies if I have placed this incorrectly or not followed any rules.

  • Request: Ability to dump the cache
  • Program: dnsdist
  • Issue type: Feature request

Short description

In my current configuration I have the following:
mc = newPacketCache(10000, 86400, 0, 60, 60)
getPool(""):setCache(mc)

This is allowing me to cache 10,000 results for 24 hours.

Currently I can remove results like so:
getPool("poolname"):getCache():expungeByName(newDNSName("powerdns.com"), dnsdist.A)

However as I do not know what is in the cache, I cannot remove bad entries or entries I am unaware of using the above method.

If possible adding a new method for example showCache():
getPool(""):showCache()

This would then print a list on screen or dump a list to a file with all the cached dns entries.

Other information

I have searched for a possible answer to no avail.
I have checked on IRC and it does not seem to be possible at this moment.

**<BillyNoNames>** I asked a similar question but pretty sure I gave nonsense information.
I have the following in my dnsdist config 
mc = newPacketCache(10000, 86400, 0, 60, 60) getPool(""):setCache(mc)
How can I actually see the records it has cached, ie print the 10,000 records? Where are these stored?
**<Habbie>** they are stored in memory.
I'm pretty sure this is all you can do with a cache: http://dnsdist.org/README/#caching.
Yes, there is no 'dump' in the implementation
dnsdist feature request

Most helpful comment

Also, it may be super useful for dnsdist graceful restart. Our software can handle hard daemon restart. But blast of requests to cold cache can overload upstreams and dnsdist.

I'm thinking about following case:

  • Set "dump cache" flag using cli
  • Gracefully stop dnsdist
  • dnsdist writes cache to disk
  • Start dnsdist with flag --read-cache
  • dnsdist read cache from disk in background (to reduce delays)
  • Working dnsdist with hot cache

I think it should reduce downtime a lot.

All 6 comments

Some ECS statistics sampling we're contemplating here would benefit from this ability as well. Some sort of wildcarded export method would be interesting, but a full dump would be "good enough."

Also, it may be super useful for dnsdist graceful restart. Our software can handle hard daemon restart. But blast of requests to cold cache can overload upstreams and dnsdist.

I'm thinking about following case:

  • Set "dump cache" flag using cli
  • Gracefully stop dnsdist
  • dnsdist writes cache to disk
  • Start dnsdist with flag --read-cache
  • dnsdist read cache from disk in background (to reduce delays)
  • Working dnsdist with hot cache

I think it should reduce downtime a lot.

pavel-odintsov: being able to inject (override? delete?) data into the cache would be useful in a more generic, real-time manner (not just load at launch) as well but that sounds like another ticket.

Yep, that's good idea for out of the band resolution. I.e. I can use custom lua code to get IP for particular qname and then manually inject it into cache.

Original request fixed by #6749

I also started this but never finished: https://github.com/phonedph1/pdns/commit/9217ae0f17f91aa59d6855d86ba0fd01201da08f

Oh, nice! I will try it :)

Was this page helpful?
0 / 5 - 0 ratings