View Single Post
  #8   (View Single Post)  
Old 7th June 2008
splooge splooge is offline
New User
 
Join Date: May 2008
Posts: 5
Default

Here's the final script, for completeness sake:

(NOTE: This required ssh keys and rndc keys for remote file access and remotely reloading named on the slave)

Code:
if [ -z "$1" ] || [ -z "$2" ]
then
        echo "Proper usage of this script is `basename $0` [domain-name] [IP address]"
        exit
fi

#Let's do the zone file ...
echo "Creating initial zone file ..."

echo "\$TTL 300
$1.                     IN SOA  ns1.pwned.com. hostmaster.pwned.com. (
                                2008060401 ; serial
                                1H         ; refresh
                                10M        ; retry
                                1D         ; expire
                                1D         ; minimum
                                )

                        NS      ns1.pwned.com.
                        NS      ns2.pwned.com.

                        A       $2
www                     CNAME   @
" > /etc/namedb/master/db.$1

echo "Changing ownership on db.$1 ..."
chown bind:bind /etc/namedb/master/db.$1

# Let's update named.conf ...
echo "Updating named.conf ..."

echo zone \"$1\"" {
        type master;
        file \"master/db.$1\";
};
" >> /etc/namedb/named.conf

# Reload named for changes to take effect ...
echo "Reloading named ..."

rndc reload

#Populate named.conf on ns2
echo "Populating named.conf on ns2 ..."

ssh ns2 'echo "zone \"'$1'\" {
        type slave;
        file \"sec/db.'$1'\";
        masters { 72.26.x.x; };
};
" >> /etc/bind/named.conf'

# Reload named on ns2
echo "Reloading named on ns2 ..."

rndc -s ns2 reload

Last edited by splooge; 7th June 2008 at 04:06 AM.
Reply With Quote