<HTML>
<HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="OPENWEBMAIL" name=GENERATOR>
</HEAD>
<BODY bgColor=#ffffff>
Ken and Richard - thanks for the suggestions ! They were both very helpful.
<br />
<br />Dan Porter
<br />Twin Wolf Technology Group
<br /><font size="2">
<br />
<br /><b>---------- Original Message
-----------</b>
<br />
From: "Ken - Precision Web Hosting, Inc"
<kenlists@precisionweb.net>
<br />
To: "BlueOnyx General Mailing List" <blueonyx@mail.blueonyx.it>
<br />
Sent: Sat, 7 May 2011 13:44:13 -0700
<br />
Subject: [BlueOnyx:07253] Re: DNS Script ?
<br />
<br />>
----- Original Message -----
<br />>
From: Dan Porter
<br />>
To: BlueOnyx General Mailing List
<br />>
Sent: Saturday, May 07, 2011 10:15 AM
<br />>
Subject: [BlueOnyx:07251] Re: DNS Script ?
<br />>
<br />>
LOL, its not difficult. The hosting customer does not have access to the
<br />>
second box and it's one of those petty little maintenance tasks that could
<br />>
be automated and eliminated. I thought perhaps someone on this list had
<br />>
already done so but maybe I am the first to consider it. We have also had
<br />>
the case of someone mistyping the domain name on the secondary DNS service.
<br />>
<br />>
Thanks Jeff !! Dan.
<br />>
<br />>
---------- Original Message -----------
<br />>
From: Jeff Folk <jfolk@qzoneinc.com>
<br />>
To: BlueOnyx General Mailing List <blueonyx@mail.blueonyx.it>
<br />>
Sent: Sat, 7 May 2011 11:36:18 -0500
<br />>
Subject: [BlueOnyx:07250] Re: DNS Script ?
<br />>
<br />>
> On May 7, 2011, at 11:06 AM, Dan Porter wrote:
<br />>
> >
<br />>
> > So the question was, is there such a script available that someone has
<br />>
> > already created to automate the creation of the secondary records
based
<br />>
> > on those from the primary - OR - what are the ramifications of simply
<br />>
> > running two primary DNS servers by just FTP'ing over the zone files
when
<br />>
> > a change is detected on the first primary DNS server?
<br />>
>
<br />>
> What is so difficult about adding a domain name and IP into the secondary
<br />>
> dns service on the second box? It isn't like you have to recreate all the
<br />>
> dns records... The complete zone file is transferred to the secondary dns
<br />>
> server (as long as you have given permission to the IP address in the
<br />>
> primary server).
<br />>
>
<br />>
> _______________________________________________
<br />>
<br />>
Dan
<br />>
<br />>
What I do is on the server hosting the sites and the dns is :
<br />>
set up a cron
<br />>
22 10 * * * /root/domainlist.sh
<br />>
<br />>
That script contains:
<br />>
#!/bin/sh
<br />>
<br />>
rm /home/sites/somesite.onyourserver.com/web/secondaryrecords.txt
<br />>
ls -1 /home/sites | grep www. >>
<br />>
/home/sites/somesite.onyourserver.com/web/secondaryrecords.txt
<br />>
chmod 766 /home/sites/somesite.onyourserver.com/web/secondaryrecords.txt
<br />>
perl -p -i -e 's/www\./secondary - /g'
<br />>
/home/sites/somesite.onyourserver.com/web/secondaryrecords.txt
<br />>
perl -p -i -e 's/\n/ 123.456.78.90 - \n/g'
<br />>
/home/sites/somesite.onyourserver.com/web/secondaryrecords.txt
<br />>
<br />>
That file contains records like the ones below, where 123.456.78.90 is the
<br />>
IP of your primary nameserver.
<br />>
secondary - oneofyourdomains.com 123.456.78.90 -
<br />>
secondary - anotherofyourdomains.com 123.456.78.90 -
<br />>
<br />>
Then on the secondary server, I get those records and inject them into the
<br />>
named.conf
<br />>
<br />>
35 21,7 * * * /root/getrecs.pl
<br />>
<br />>
That file contains:
<br />>
<br />>
#!/usr/bin/perl
<br />>
<br />>
$aproblem = "nothing";
<br />>
<br />>
system ("rm secondaryrecords.txt secondaryrecords.txt.* ");
<br />>
<br />>
$filetoget = "<a target="_blank" href="http://123.456.78.90/possiblysomedir/secondaryrecords.txt">http://123.456.78.90/possiblysomedir/secondaryrecords.txt</a>";
<br />>
$wgetinfo = `wget $filetoget 2>&1`;
<br />>
if ($wgetinfo !~ /200 OK/i) { print "We have a problem with $filetoget ,
<br />>
will exit. Info is $wgetinfo"; exit; }
<br />>
<br />>
$filetoget = "<a target="_blank" href="http://123.456.78.99/possiblysomedir/secondaryrecords.txt">http://123.456.78.99/possiblysomedir/secondaryrecords.txt</a>";
<br />>
$wgetinfo = `wget $filetoget 2>&1`;
<br />>
if ($wgetinfo !~ /200 OK/i) { print "We have a problem with $filetoget ,
<br />>
will exit. Info is $wgetinfo"; exit; }
<br />>
<br />>
$filetoget = "<a target="_blank" href="http://223.456.99.101/secondaryrecords.txt">http://223.456.99.101/secondaryrecords.txt</a>";
<br />>
$wgetinfo = `wget $filetoget 2>&1`;
<br />>
if ($wgetinfo !~ /200 OK/i) { print "We have a problem with $filetoget ,
<br />>
will exit. Info is $wgetinfo"; exit; }
<br />>
<br />>
system ("cat secondaryrecords.txt secondaryrecords.txt.* >
allrecords");
<br />>
<br />>
open (IN, "<allrecords") or die "Couldn't open input CSV
file: $!";
<br />>
<br />>
my @allsortedrecords = sort <IN>;
<br />>
<br />>
system (" cp /root/orignamed.conf /root/named.conf");
<br />>
open(NAMEDCONF," >> /root/named.conf");
<br />>
<br />>
$lastline = '';
<br />>
<br />>
foreach $thisline (@allsortedrecords) {
<br />>
($prev0, $nothing, $domain, $ipaddress, $prev4) =
split(/\s+/,$thisline);
<br />>
#print "prev0 $prev0, nothing $nothing, domain $domain, ip
$ipaddress,
<br />>
nada $prev4";
<br />>
#print "The domain is $domain \n";
<br />>
if ($domain eq $lastdomain) {
<br />>
print "$domain eq $lastdomain
----------------------------- \n\n";
<br />>
$aproblem = $lastline;
<br />>
#exit;
<br />>
next;
<br />>
} else {
<br />>
if (($domain =~ /\s/) or ($ipaddress !~
/\d+\.\d+\.\d+\.\d+/) or
<br />>
($domain =~ /in-addr.arpa/) or ($thisline eq
<br />>
$lastline) ) {
<br />>
print "domain $domain then ip is
$ipaddress or thisline eq last
<br />>
$thisline eq $lastline next\n";
<br />>
next;
<br />>
}
<br />>
print NAMEDCONF "zone \"$domain\"
\{\n";
<br />>
print NAMEDCONF " type slave;\n";
<br />>
print NAMEDCONF " file
\"db.$domain\";\n";
<br />>
print NAMEDCONF " masters \{ $ipaddress;
\};\n";
<br />>
print NAMEDCONF "\};\n\n";
<br />>
<br />>
#if ($lastline eq "precisionweb.net") {
<br />>
# print "This line is $thisline";
<br />>
# print "Last line is $lastline";
<br />>
# exit;
<br />>
#}
<br />>
$lastdomain = $domain;
<br />>
}
<br />>
<br />>
}
<br />>
close(NAMEDCONF);
<br />>
<br />>
system ('rm -f /var/named/chroot/etc/named.conf');
<br />>
system ('cp /root/named.conf /var/named/chroot/etc/named.conf');
<br />>
#system ('/etc/rc.d/init.d/named restart');
<br />>
<br />>
$restart =`/etc/rc.d/init.d/named restart`;
<br />>
<br />>
print "The restart is $restart";
<br />>
<br />>
if ($restart =~ /FAILED/) {
<br />>
print "We have a problem with restart. It was $restart \n\n";
<br />>
#copy the old file in and try again
<br />>
#email me
<br />>
<br />>
} else {
<br />>
print "All is fine\n The restart was $restart";
<br />>
<br />>
}
<br />>
<br />>
if ($aproblem ne "$aproblem" ) {
<br />>
print "A problem line was $aproblem\n";
<br />>
}
<br />>
<br />>
So, it gets secondary lists from multiple servers, sorts them, checks for
<br />>
duplicates, injects them into a template file, then copies that to the
<br />>
named.conf I'm sure there are better ways to do it, but that is what I use
<br />>
for customer dedicated VPS
<br />>
<br />>
----
<br />>
Ken M
<br />>
Precision Web Hosting, Inc.
<br />>
<a target="_blank" href="http://www.precisionweb.net/">http://www.precisionweb.net</a>
<br />>
<br />>
_______________________________________________
<br />>
Blueonyx mailing list
<br />>
Blueonyx@mail.blueonyx.it
<br />>
<a target="_blank" href="http://mail.blueonyx.it/mailman/listinfo/blueonyx">http://mail.blueonyx.it/mailman/listinfo/blueonyx</a>
<br /><b>------- End of Original Message
-------</b>
<br />
</font>
</BODY>
</HTML>