4

I currently have a DNS server which is serving as a master DNS server for a number of our domains. I want to set up a brand new secondary DNS server. Is there any way I can automatically have BIND on the new server act as a secondary for all the domains on the primary server?

In case it matters, I have Webmin on the primary server. I believe Webmin has an option to create a zone as a secondary on another server when creating a new master zone on one server, but I don;t know of any way to batch create secondary zones for a number of existing master zones. Maybe I'm missing something.

Is there a way to "batch create" DNS slave zones on a brand new slave DNS server for all the DNS zones on an existing master?

10

Writing a script to do this shouldn't take very long, especially if you name the zone files after the domain.

ls master.dir > domain.list

foreach domain (`cat domain.list`)
echo 'zone "$domain" { type slave; file "slave/$domain"; masters { 1.2.3.4 }; };' >> named.conf.slaves
end

And add include named.conf.slaves; to your named.conf

  • +1 for smart way. And of course "rndc reconfig" after this. – plluksie Jan 11 '11 at 20:20
  • 2
    +1 And just make sure that the relevant allow-transfer (4.3.2.1;} is either the options stanza so that the server can transfer all zones. Alternatively, make sure that allow-transfer(4.3.2.1;} is in each zone that the slave will be pulling. This presumes the slave is at 4.3.2.1 – Niall Donegan Jan 11 '11 at 21:14
2

Since this got bumped to the front page anyway:

Configure rndc and on set the the option

 allow-new-zones yes;

in your named.conf. Then you can add new slave zones from the command line (without manually editing the named.conf on the slave) with

rndc addzone example.com '{ type slave; masters { master_ip; }; };'
rndc reconfig

which can easily be scripted and repeated for any additional zone you want to add.

  • OK, round of applause from me. And +1. – MadHatter Jul 1 '18 at 20:10
1

In Webmin, when you configure a new slave, you will be given the option to copy over all zones on the master to the new slave. The Virtualmin docs have a section about slave DNS servers, and if you're only using Webmin, you'd just skip the end bits about making Virtualmin use the slave server. The steps for Webmin are the same.

http://www.virtualmin.com/documentation/dns/slave-configuration

Specifically, the option you want is "Create all existing master zones on slave?" which will copy over all the data.

Webmin can also turn the slave into a master in the future, if needed.

0

Scripting will probably be required. Get a list of all domains you are master for, and use that list to setup the slave configs.

You will also probably need to setup the masters to allow transfers from the slave server. Another option is TSIG ( http://www.cyberciti.biz/faq/unix-linux-bind-named-configuring-tsig/ )

0

The easiest way would to be to copy the configuration from the master.

A short perl script should be able to replace the master keyword with slave and add the pointer to the master.

As Christopher noted, you will also need to modify the configuration of the master to allow zone transfers from the master.

I also noticed a security notice for bind which indicates that you should ensure all your zones have an allow-query clause.

0

Taking into account what was said before, I have adapted the shell script from Chris S. The script first check if the export file exists and if yes it deletes it to be able to run this script several times and without getting several occurrences of the same zone. export.list isn't a pre existing file that is part of BIND so no worries. It gets the list of domains, then it removes the 3 last chars of the file(db) (format of zone file is domain.tld.db) to get the zone and write the right directive for every zone.

#!/bin/bash
ls *.db > domains.list
if [ -f export.list ]; then
rm export.list
fi
for domain in `cat domains.list`; do
domain1="${domain::-3}"
echo "zone \"$domain1\" { type slave; file \"slaves/$domain\"; masters { 
XX.XX.XX.XX; }; };" >> export.list
done

then I can copy and add the content of export.list to /etc/named.conf at the bottom of the file of my secondary nameserver.

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.