I'm looking into setting up a PowerDNS server to handle a few hundred zones. I'd like to keep track the "usage" of each zone and record, i.e. the number of queries per day to each.

I couldn't find any details in the documentation or in Google on how I might achieve this. I'm unfamiliar with PowerDNS, but thinking a custom PipeBackend is needed? Do PipeBackends replace a standard MySQL backend, in addition to, or only for unresolved queries?


PowerDNS cannot currently do this. There are external tools, like dsc that can do stats via pcap.

If you were to write a custom (pipe)backend for this, it would have to replace your mysql-backend -- you can't tell powerdns to feed results from one backend through another. 'pipebackend' is perhaps a bit confusing in that sense.

Note that any statistics you would do from a backend (be it a custom backend, or be it your mysql query log) would be skewed by the (optional, but recommended) packet- and query-cache inside PowerDNS.

So, right now I would recommend using something like dsc.


As for the the pipe backend question:

All backends are exhausted for queries in the order that they are given in the launch statement. As soon as a backend responds with data matching the query all remaining backends will not be asked any further. So if you put a pipe backend that is just for generating statistics and not answering anything upfront you will catch all queries to you nameserver except those PowerDNS was able to answer from its packet and query caches.


Maybe the best option is adding a LUA hook before the PowerDNS cache options (packet- and query-cache). This way you can create a LUA script for the logging and let a backend answer the query. This way you can use the cache (for great performance) and use a tested backend (gmysql) for the response. You could even include some code to stop logging if it slows down your system to much.

If I'm correct there is already a LUA hook available just after the cache. For what you are looking for and also for rate limiting (when that is needed).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.