[BETA] DNS master2slave

First note that using MyDNS is not a slam-dunk; you'd have to run some kind of system to import information from the MySQL zone files DA maintaines, and then you'd have to run replication to get the information over to the slaves.

When we tried MySQL replication (about a half year ago) we were successful in local networks but not across the Internet; it worked for a while, but usually failed within less than an hour. We discussed the issue with the author of the replication howto we found on the 'net (he's considered somewhat of an expert on replication) and he offered to help us for money, but he also wrote that replication was not designed to work over the 'net and probably wouldn't.

That's a wide open statement. How? using MyDNS instead of BIND? BIND is the most popular DNS server on the 'net; much of the 'net runs on BIND. And while BIND doesn't directly support copying of zone names between masters and slaves, it supports zone import, which MyDNS does not; with MyDNS you've got to either get replication to work, or find some other way to replicate the databases on a continuous basis.

Neither MyDNS nor djbdns/tinydns (Dan Bernstein's suite) follow the RFCs as well as BIND, and continued study has made up my mind; we'll stick with BIND :) .

Jeff

I really don't have any problems with MySQL replication over WAN -- one of the slave replicators is located in Germany (master and other slave are in the Netherlands) and every dns update gets almost instantly replicated. And even if you've got unstable, disconnecting connections, the replicator should (default) retry every 60 seconds to reconnect. Which version(s) of MySQL did you test? Though I don't want to convince you, you should know it can actually work great ;)
 
I really don't remember. At the time Onno was in the Netherlands and I was here in California, in the US.

I'm glad it works for you, but I've moved on :) .

Jeff
 
Hey Jeff,

Is it safe to install the master2slave anytime or do I need to do it during a maintenance window?

Thanks :)
 
Ok, well I went ahead and tried it, and I think I'm having some issues... Maybe some of you can help.

Are the zone .db files supposed to get transferred over? Because I tried it by running it manually, then I tried using nslookup using the slave server and it failed on some of the domains...

How do I know if its working? I do get a slave named.conf file, but it only has the zone lines, none of the .db files that those zone lines are pointing to get carried over.

Any ideas?


EDIT - I'm getting file not found errors in /var/log/messages on the slave server...
 
Last edited:
Ok, after some tinkering and testing out...

the file part of the zone line on the slave server has to be the same as the location of the zone file on the master.

ie:

On my DA master, the zone files are at /var/named/somedomain.com.db

Using master2slave, it creates the zone lines and has them point to (after I configure it): /var/named/chroot/var/named/slaves/namedftp/XXX.XXX.XXX.XXX/somedomain.com.db

That is why I was getting the file not found errors when it was trying to load the zones from the master server.

Now my main issue is do I recode the script to have it set the zone files to point to /var/named/somedomain.com.db? or do I figure out how to get them linked correctly. I wonder if my issue lies in the way I configured it.

I'll report back with more info shortly. If anyone has some suggestions please post them! :)
 
I like this slave DNS idea for non-DA servers. But I think this can be simplified quite a bit. DNS zone information can already be transferred though DNS from master to slave when bind is configured correctly. Then, you only need to provide the slave server the /etc/virtual/domains file so it can add or remove slave entries modified on the master DA server.

Here is my current master options which allow me to transfer zones to my slave:
Code:
options {
        directory "/var/named";
        dump-file "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        allow-transfer { <my_slave_ip>; };
        recursion no;
        notify yes;
};

then on the slave, you just need the domain list to create the slaves.named.conf to each have a line like this:
Code:
zone "domain.net" { type slave; masters { <master_ip>; }; file "/var/named/slaves/domain.net.db"; };

This will let bind do all the transferring and updates based on the SOA timeouts set. The real catch again, is how to get the DA domains list to the slave server to run a simple script to check the list and update the slaves.named.conf. Looks like the same issue is presented in master2slave. The http method may be the best that I can think of.
 
The real catch again, is how to get the DA domains list to the slave server to run a simple script to check the list and update the slaves.named.conf. Looks like the same issue is presented in master2slave. The http method may be the best that I can think of.

That is what master2slave does. When you set up master to slave to run as a cron job on both the master DA server and the slave (doesn't have to be DA), it updates the list of slave domains that bind will pull zone information from.
 
Ok, after some tinkering and testing out...

the file part of the zone line on the slave server has to be the same as the location of the zone file on the master.

ie:

On my DA master, the zone files are at /var/named/somedomain.com.db

Using master2slave, it creates the zone lines and has them point to (after I configure it): /var/named/chroot/var/named/slaves/namedftp/XXX.XXX.XXX.XXX/somedomain.com.db

That is why I was getting the file not found errors when it was trying to load the zones from the master server.

Now my main issue is do I recode the script to have it set the zone files to point to /var/named/somedomain.com.db? or do I figure out how to get them linked correctly. I wonder if my issue lies in the way I configured it.

I'll report back with more info shortly. If anyone has some suggestions please post them! :)


Fixed my issue. See thread here: http://www.directadmin.com/forum/showthread.php?t=17230
 
Jeff, I had a suggestion for the future version also. I may end up coding this into the script that I have working now. Some form of logging would be good. Logging to a rotated log file or something, where you can see if the slave file was transferred properly would be good. :)
 
That is what master2slave does. When you set up master to slave to run as a cron job on both the master DA server and the slave (doesn't have to be DA), it updates the list of slave domains that bind will pull zone information from.

From what it looked like to me, it was pulling all the actual zones and zone data, not just the list of domains. I'll look at the script more closely again. Though I think I may also take a crack a writing my own. This script has a good idea. Just wish there was an easier way than having to use http and a cron to transfer the data... Maybe there is a pre and post DA script for DNS edits and changes?
 
Jeff, I had a suggestion for the future version also. I may end up coding this into the script that I have working now. Some form of logging would be good. Logging to a rotated log file or something, where you can see if the slave file was transferred properly would be good. :)

Another thing I'd like to add is the ability to use SCP instead of over the http. I think having the keys already set up would make the scp ability work pretty well. Then you would be able to create a specific user to scp the files over.
 
Does MSWindows support ssh/scp?

The beauty of using httpd is that you can get what you need from any kind of server.

Of course you can rewrite it to do anything you want; that's the beaty of open source :) .

Jeff
 
Hi. When I run getmaster2slave.dns.sh on freebsd6.2 as su - namedftp -c './getmaster2slave.dns.sh' all works fine.
But if I run this script through cronjob, wget (or fetch) fails, no errors, just standart message, but zone file isn't downloaded((
Please help
 
Hi. When I run getmaster2slave.dns.sh on freebsd6.2 as su - namedftp -c './getmaster2slave.dns.sh' all works fine.
But if I run this script through cronjob, wget (or fetch) fails, no errors, just standart message, but zone file isn't downloaded((
Please help

Problem solved. You need to use direct paths in getmaster2slave.dns.sh and to wget.
 
Master2Slave sounds very interesting. I'm running a Vanilla DA server and I've configured master2slave. It puts the file into the web root correctly. Only problem is... It doesn't contain any information at all! Here's a few lines of what it puts in the file:

# Created by master2slave
zone "example" { type master; file "/var/named/example.com"; };
zone "example2.com" { type master; file "/var/named/example2.com"; };

Did DA change it's way of dealing with the DNS since this script was last updated? Do I need to change something in my bind settings?

Any help would be highly appreciated.
 
I don't understand. First you say it doesn't contain any information, then you show us an example that does contain information.

Please explain in more detail.

Thanks.

Jeff
 
I don't understand. First you say it doesn't contain any information, then you show us an example that does contain information.

Please explain in more detail.

Thanks.

Jeff
Jeff, that's the exact point. It's listing the domain names with a local path to the file probably containing the zone information about the specific domain.
Notice that it saying "/var/named/example.com". I would suspect that if it would be working correctly, it would be containing IP addresses and information about the zone, rather than a path to a local file.

I mean... If it's containing references to local files, how do you want the remote server to access it?

Is this more clear?
 
I think I'm beginning to understand your post. A master record should look like this one for my nobaloney.com domain:
Code:
zone "nobaloney.com" { type master; file "/var/named/nobaloney.com.db"; };
On your slave server, unless you're also running master records the last lines in your /etc/named.conf file should look something like this:
Code:
include "/etc/rndc.key";

include "/var/named/slaves/slaves.named.conf";
and there should be no other lines.

In your /var/named/slaves/slaves.named.conf file you should see something like this:
Code:
zone "nobaloney.com" { type slave; file "/var/named/slaves/namedftp/4.79.140.132/nobaloney.com.db"; masters { 4.79.140.132; }; };
Your actual slave zone files should be in your /var/named/slaves/namedftp/IP# (where IP# should be replaced by the IP# of your master directory).

If your system doesn't look like that, then either you've somehow made an error in your installation, or you may have been manually managing your slave server before. If you've been manually managing your slave server before, then it's possible your nameserver isn't serving any zones at all; watch your /var/log/messages file immediately after restarting the nameserver. On a RedHat/CentOS/Fedora server you'd do:
Code:
# service named restart ; tail -f /var/log/messages
If you see duplicate errors then you need to remove lines from your /etc/named.conf file for each line with an error, and then restart again.

(You can get out of the tail command with a Ctrl-C.)

Note that according to the creators of BIND, there's no such thing as a master server and a slave server; the status is by individual domain. I sometimes use the term master server to represent the BIND service running under DirectAdmin control, and the the term slave server to represent the server you run which only hosts slave domains.

If you're running DirectAdmin, and hosting sites, on both servers, you'd probably be better off with the DirectAdmin Multi Server Setup facility, available from the DirectAdmin admin login.

Note that if you're having trouble with Master2Slave we can do installs/uninstalls for you at very reasonable per-server rates. Please contact us by email (address below in my siglines) for more information.

Jeff
 
For what linux distro is master2slave written?
Becouse I use Debian Etch and the paths etc are totaly different (/etc/bind/ instead of /var/named/)

On first hand that did not matter.. I adjusted the scripts to match my distro but I cant seem to get the cronjob for reloading bind working.
I had to use /etc/init.d/bind 9 reload

but when I try to run it as a cronjob it just wont run... no errors or anything...
 
For what linux distro is master2slave written?
I wrote it for RedHat variations. I thought that they used standard locations; evidently I'm wrong.
Becouse I use Debian Etch and the paths etc are totaly different (/etc/bind/ instead of /var/named/)
You'll have to make the adjustments yourself; I don't run any Debian servers.
On first hand that did not matter.. I adjusted the scripts to match my distro but I cant seem to get the cronjob for reloading bind working.
I had to use /etc/init.d/bind 9 reload

but when I try to run it as a cronjob it just wont run... no errors or anything...
What's the 9 for?

Jeff
 
Back
Top