0

In need of a MySQL backend for my DNS server, I have decided to switch from Bind to PowerDNS, the MySQL backend of which is slightly more convenient.

Basically : users add domains to my database using a web frontend, those domains are registered and available to PowerDNS. When I query the DNS server about these domains, I get a valid response. Works like a charm.

The fact is, I need to add domains and zones of mine to my DNS registries, and adding them to the database would break my application's logic (only users of this application should be adding domains). I would like to add extra domains and zones to PowerDNS, without adding them to my database directly.

Is there any way I could register additional domains, in a file for instance, which would be read before any MySQL query is made ? Or maybe a fallback file, in case nothing's found among my MySQL records ?

John WH Smith
  • 341
  • 4
  • 18

1 Answers1

0

Solution found, in the depths of the PowerDNS launchpad ! There is a way to read DNS-data files before using the MySQL backend, and that is... using two backends ! Quoting :

As described in http://doc.powerdns.com/modules.html - just not with so many words ;) - PowerDNS can launch any number of different or oven the same backends via the launch statement. Usually one would just do that in the configuration file pdns.conf instead of the command line. Those backends will be exhausted for answers to your DNS query in the order in which they are given in the launch statement. This does mean that if your first backend in line can answer the question, it will and if only the fourth in line can answer the question you will have the delay of the looping through the first three backends until PowerDNS will send out the answer. It is therefore imperative that you make sure that your backends do answer fast enough where fast enough would be receiving and answer in <1s should be enough to be compatible with most recursive nameservers, however faster is better of course.

For my problem, I chose to use :

  • A Bind backend, which serves as the prioritary file-based backend.
  • The MySQL backend, which comes second.

Basically, all it takes is a little configuration change in pdns.local :

launch=bind,gmysql

I've heard you could be even more specific with (assigns names to backends) :

launch=bind:first,gmysql:second

Then, just add parameters for both backends :

# Bind backend configuration
bind-config=/path/to/your/zones/file

# MySQL configuration
gmysql-host=localhost
gmysql-port=
gmysql-dbname=db
gmysql-user=user
gmysql-password=passwd
gmysql-dnssec=no

All you have to do is create a Bind zone file (zone{} blocks) referring to domain-specific files (containing SOA, A, MX, NS, ... records).

Restart !

John WH Smith
  • 341
  • 4
  • 18