Way to batch create DNS slave zones on a new slave DNS server

binddomain-name-system

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?

Best Answer

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