Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am going to start a new website which is going to require DNS servers. It might have over 10,000 zones and will get more zone files as we get bigger. The problem is, which dns server software do you think is more efficent: mydns which uses mysql to store the data or bind which uses flat files? How do these DNS servers handle load balancing so we can balance the load between several servers so any one doesn't overload?

share|improve this question
Wow I'd never heard of MyDNS before, looks interesting. A question like this will probably come down to history. BIND is old, trusted and reliable. There is also a huge amount of documenation and resorces about BIND. Similar to the way people would still chose to use Apache over say LIGHTTPD or NGINX, Apache is truested, even though it might not be the better solution – Smudge Jun 27 '11 at 13:33
Also I guess it comes down to how many records you're going to serve, storing 10k zones might require a good chunk of disk space, but if you only get one lookup a day, performance is probably irelevant. Do you know ~how many lookups there will be and are you distributing it over 2 or 3 DNS servers or just the one? – Smudge Jun 27 '11 at 13:34
Dup of:… – Ward Jun 27 '11 at 13:38
Have you excluded djbdns, PowerDNS, nsd, and MaraDNS from consideration? – JdeBP Jun 27 '11 at 13:55
@Nesh, to heck with "most efficient", stick with the software you're most familiar with and which suits your other needs. The disk space for that many domains is almost trivial. I wouldn't worry how the software "handles load" so much as knowing you have enough CPU/RAM to handle spikes in traffic. Also, while you might expect to get to 12krps "if when we get more popular", you're probably better off sizing for your current load and scaling as you grow (dns scales very well). – Chris S Jun 28 '11 at 12:38

To my maind, BIND is better. It is easy to configure, you don't need to restart BIND except when you upgrade the software. What you should look into for BIND is the rndc command. Rndc allows you to reload an individual zone, while leaving BIND running. If you've edited the zonefile, rndc will publish the changes immediately.

It absolutely is possible for BIND to run off a database. You need to specify some steps in the ./configure step.

I have some good instructions but they are in russian. I'll try to write a little plan of action.

  1. It is assumed that MySQL-server already installed and configured.
  2. Download mysql-bind project from off. the site (there, we need two files: mysqldb.c and mysqldb.h).
  3. Jump to the folder with the downloaded file to extract:

    cd ~ / downloads / tar -xzf mysql-bind.tar.gz

  4. Jump to the port and download the source bind9 (your version of mysql-bind is designed for this service). While not compile!

    cd /usr/ports/dns/bind9 make fetch extract

  5. Copy the downloaded files mysql-bind to bind's sources:

    cp ~/downloads/mysqldb.c /usr/ports/dns/bind9/work/bind-x.x.x/bin/named/ cp ~/downloads/mysqldb.h /usr/ports/dns/bind9/work/bind-x.x.x/bin/named/include/named/

  6. Jump to the folder with the source (work / bind-xxx) and make the following changes: a) The file bin/named/ read:

    DBDRIVER_OBJS = mysqldb.@O@ DBDRIVER_SRCS = mysqldb.c

    Run the command mysql_config -cflags and write the output to a variable DBDRIVER_INCLUDES (example: DBDRIVER_INCLUDES = -I/usr/local/include/mysql -fno-strict-aliasing -pipe)

    Run the command mysql_config -libs and write the output to a variable DBDRIVER_LIBS (example: DBDRIVER_LIBS = -L/usr/local/lib/mysql-lmysqlclient-lz-lcrypt-lm)

    b) In the file bin/named/main.c:

    • Adding a header file #include <named/mysqldb.h>
    • Inside the function setup(), add a call mysqldb_init() before the line ns_server_create().
    • Inside the function cleanup(), add mysqldb_clear(); after ns_server_destroy().
  7. Install Bind:

    cd /usr/ports/dns/bind make make install

  8. Create for each zone, its table mysql:

    CREATE TABLE table_name ( name varchar(255) default NULL, ttl int(11) default NULL, rdtype varchar(255) default NULL, rdata varchar(255) default NULL ) TYPE=MyISAM;

  9. Create the necessary records for the zone:

    INSERT INTO table_name VALUES ('', 259200, 'SOA', ' 2008092901 28800 7200 86400 28800'); INSERT INTO table_name VALUES ('', 259200, 'NS', ''); INSERT INTO table_name VALUES ('', 259200, 'NS', ''); INSERT INTO table_name VALUES ('', 259200, 'MX', '10'); INSERT INTO table_name VALUES ('', 259200, 'A', ''); INSERT INTO table_name VALUES ('', 259200, 'A', '');

  10. In the named.conf file prescribe the correct zone:

    zone "" { type master; notify no; database "mysqldb database_name table_name mysql_ip_address login password"; };

  11. Pay special attention, in the last line should specify the username and password. Information is stored in an unencrypted form, which of course is dangerous! So there are two ways: as something tricky to keep the code in the encoded code or in the database to create a user login-"bind" and pass-"bind" and put it privilege select.
  12. I apologize for my English. Hope this helps.
  13. the instruction is written for freebsd, for Linux should be similar
share|improve this answer
Would mysql database take more resources than zone files because I making a script and I would prefer to use database because its much easier to add records then opening file on php, and I have tried using mysql as a backend for bind but It never works, do you have a good tutorial that can guide me and thanks for your help? – Nesh A Jun 27 '11 at 14:03
thanks this is really useful. – Nesh A Jun 27 '11 at 18:52 will create tables for each zone you add, its really bad if you are going to host over 100k of zones.

share|improve this answer
What's bad? mysql-bind or just the OP's question? – Caleb Jun 30 '11 at 7:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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