PowerDNS / pdns

PowerDNS Authoritative, PowerDNS Recursor, dnsdist
https://www.powerdns.com/
GNU General Public License v2.0
3.61k stars 900 forks source link

Dump Cached DNS requests #4644

Open jonpaulh opened 7 years ago

jonpaulh commented 7 years ago

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

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
johnhtodd commented 6 years ago

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."

pavel-odintsov commented 6 years ago

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:

I think it should reduce downtime a lot.

johnhtodd commented 6 years ago

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.

pavel-odintsov commented 6 years ago

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.

phonedph1 commented 6 years ago

Original request fixed by #6749

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

pavel-odintsov commented 6 years ago

Oh, nice! I will try it :)