BIND tool for setting up secondary records?

John Nielsen lists at jnielsen.net
Fri Jan 26 16:02:09 UTC 2007


On Friday 26 January 2007 10:50, Robert Fitzpatrick wrote:
> I am not a member of a BIND list, so I thought I'd ask here first if
> anyone knows of a script tool that will query a primary name server and
> setup secondary records on another BIND server? Or any other solution
> for doing mass entries of domains to a BIND server to setup secondary
> records with the same primary master?

If you set up a slave domain it will automatically query and stay in sync with 
the master nameserver.

I use scripts on both ends for most new domains. Here's the files from the 
slave side:

=== begin addconf.sh ===
#!/bin/sh
DATADIR="/etc/namedb/conf"
TEMPLATE="/etc/namedb/templates/default.bind"

usage() {
        echo "Usage: $0 \"domain.name\" [templatefile]"
        exit 1;
}

if [ "$2" ] ; then
        if [ -r $2 ] ; then
                TEMPLATE=$2
        else
                usage
        fi
fi

if [ "$1" ] ; then
        DOMAIN=$1
else
        usage
fi

echo -n "Configuring ${DOMAIN} using ${TEMPLATE}.."
cat ${TEMPLATE} | sed -e "s/%%DOMAIN%%/${DOMAIN}/g" > 
${DATADIR}/${DOMAIN}.bind
echo " done."
=== end addconf.sh ===

=== begin default.bind ===
zone "%%DOMAIN%%" {
        type slave;
        file "slave/%%DOMAIN%%.bak";
        masters { my.master.server.ip; };
        allow-query { 0.0.0.0/0; };
};
=== end default.bind ===

=== begin make-conf.sh ===
#!/bin/sh
inputfile=/etc/namedb/templates/named.conf.in
outputfile=/etc/namedb/named.conf
backupfile=/etc/namedb/backups/named.conf.old
confdir=/etc/namedb/conf

if [ -r ${outputfile} ] ; then
        echo "Backing up current file to ${backupfile}.."
        mv -f ${outputfile} ${backupfile}
fi
echo -n "Generating ${outputfile}"..
cp -f ${inputfile} ${outputfile}
for conffile in ${confdir}/*.bind; do
        echo "include \"${conffile}\";" >> $outputfile
done
echo " done."
=== end make-conf.sh ===

For named.conf.in you just want your normal named.conf file that doesn't 
include any of the domains defined in ${confdir}. Figuring out the rest of it 
I leave as an exercise for the reader, but I'm happy to answer specific 
questions.

JN


More information about the freebsd-questions mailing list