Solved

Secondary DNS, Zone Transfer

Posted on 2010-09-22
6
1,406 Views
Last Modified: 2013-12-26
Hi! I'd like to set up a secondary DNS server. My primary server supports zone transfers and everything works fine. I tested this with my live primary DNS server and a local development machine with Bind9 and Webmin. I used Webmin to create the slave zone for testing.

However, what I'd also like to do is make a frontend web-based GUI simply for adding slave zones. My preferred programming language is PHP, and I thought MySQL would do the job nicely for keeping zone information.

My question is about getting Bind to read and process the information from the MySQL database. What's the best way to go about doing this? It will be very basic because all I'm doing is adding a zone and then specify the primary DNS server's IP address. I don't need to add any host records because these will be fetched from the primary NS. It's my understanding that all I need is the following in my named.conf.local file:

zone "example.com" {
        type slave;
        masters {
                123.456.136.13;
                };
        file "/var/lib/bind/example.com.hosts";
};

Open in new window


... and Bind will do the rest - i.e. update the /var/lib/bind/example.com.hosts file. Assuming that's correct, what's the best way to retrieve the data from MySQL and then update the named.conf.local file in /etc/bind?
0
Comment
Question by:Julian Matz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 3

Accepted Solution

by:
beezleinc earned 250 total points
ID: 33741065
Not following you.   Yes BIND will take care of updating the secondary's zone file (example.com.hosts in this case) when triggered by the zone's primary BIND server (actually when it detects the primary zone's serial number changes).   Keeping zone info in MySQL is a fine idea.  You will need a script (php) to rebuild the named.conf config files and kick off BIND (i.e.  kill -1) to reload the config files.   I don't believe BIND can create or recreate it's own config files from a database.
0
 
LVL 26

Assisted Solution

by:jar3817
jar3817 earned 125 total points
ID: 33745029
Bind will not be able to load the zone data from MySQL. There is a patch for it, but I've never gotten it to work right.

You'll have to export the data either using a cron job or a button on the web interface. Cron will most likely be easier since you'll have to edit files owned by root, unless you give apache write permissions.

Write a script (php or bash or whatever) that pulls the zone info out of mysql and spits it out into a named.conf file. Then have your script call "rndc reload"
0
 
LVL 21

Author Comment

by:Julian Matz
ID: 33747141
Thanks! Appending the named.conf.local file will be easy enough to add zones, but where I'd get stuck is updating zones and also checking to see if a zone already exists in the file.

Basically, adding a zone is fine but how to keep named.conf.local in sync with the database?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 21

Author Comment

by:Julian Matz
ID: 33747169
Or should I rebuild the named.conf.local file each time a new record is added to the database? Would that be better?
0
 
LVL 3

Assisted Solution

by:beezleinc
beezleinc earned 250 total points
ID: 33769494
Ideally your script should be able to rebuild the bind config files at any time from the data in your database.  
0
 
LVL 5

Assisted Solution

by:maques
maques earned 125 total points
ID: 33829406
I suggest you to use one-liners in the zone.conf, eg.:
zone "example.com" { type slave; masters {123.456.136.13;}; file "/var/lib/bind/example.com.hosts"; };

then any line based search/tool could find/remove a domain easily, like grep [-v] "example.com"...

I use it with several thousand domains, makes scripted management an easypie.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Resolve DNS query failed errors for Exchange
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question