offsite DNS (master and slave) solution

Discussion in 'Tips/Tricks/Mods' started by jorizzzz, Feb 11, 2009.

  1. jorizzzz

    jorizzzz New Member

    Hi guys,

    I've been struggling a while to get my setup working as i like... In the old setup i had 2 webservers with ISPConfig installed on it. Server 2 was the slave DNS for server 1 and viceversa. This was getting a bit out of hand so i needed a new solution.

    I've got two servers (vmware instances) with a new linux installation and only bind installed on the two of them. Below is a plan that i've used for this solution to work. Hopefully it can do good for you too.

    If you see anything that's off or that could be done better, please respond! I'm always in for a bit finetuning.

    Oh yeah, i've used public key authentication for the scp to work...

    1. Copy all of the zone files to the primairy DNS
    Webserver 1:
    scp /etc/bind/pri.* [email protected]:/home/dns/zones
    Webserver 2:
    scp /etc/bind/pri.* [email protected]:/home/dns/zones
    2. Import zone files in master dns server and copy the zonelist to the slave server. Add the following line to named.conf to make bind look into the zones.conf file:
    Include /etc/bind/zones.conf
    mv /home/dns/zones/pri.* /etc/bind/
    rm /home/dns/zonelist
    echo > /etc/bind/zones.conf
    for a in $(ls /etc/bind/pri.*); do echo ${a#/etc/bind/pri.} >> zonelist; done
    for i in `cat /home/dns/zonelist`; do
    echo "zone \"$i\" {" >> /etc/bind/zones.conf
    echo " type master;" >> /etc/bind/zones.conf
    echo " file \"/etc/bind/pri.$i\";" >> /etc/bind/zones.conf
    echo "};" >> /etc/bind/zones.conf
    echo >> /etc/bind/zones.conf
    /etc/init.d/bind9 force-reload > /dev/null
    scp /home/dns/zonelist [email protected]:/home/dns/

    3. Import the slave zones on the slave DNS server. add the following line in named.conf to tell bind.
    Include /etc/bind/slave-zones.conf
    echo > /etc/bind/slave-zones.conf
    for i in `cat /home/dns/zonelist`; do
    echo "zone \"$i\" {" >> /etc/bind/slave-zones.conf
    echo " type slave;" >> /etc/bind/slave-zones.conf
    echo " file \"slave.$i\";" >> /etc/bind/slave-zones.conf
    echo " masters {; };" >> /etc/bind/slave-zones.conf
    echo " notify no;" >> /etc/bind/slave-zones.conf
    echo "};" >> /etc/bind/slave-zones.conf
    echo >> /etc/bind/slave-zones.conf
    /etc/init.d/bind9 force-reload > /dev/null
    rm /home/dns/zonelist
    You can alltime this with cronjobs :) hopefully it will do good :)

    Ok guys, i've been testing a bit and this here isn't working quite yet... I'm having troubles with inserting the zones into the master DNS... I will adjust the code when it does work. If anyone of you got it right, please post it!

    *update* I've got it working! above is how i've done it.
    Last edited: Feb 11, 2009
  2. id10t

    id10t Member

    Looks good. Only change I'd make is to not delete the files before re-creating them, but instead make a backup of 'em all into a tar file that is time/date stamped, so should something Go Wrong you can always recover. Maybe back up the actual zone files as well at the same time...

Share This Page