[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cobalt-developers] Importing DNS Records
- Subject: Re: [cobalt-developers] Importing DNS Records
- From: "Taco Scargo" <taco.scargo@xxxxxxx>
- Date: Thu Mar 7 16:47:02 2002
- List-id: Discussion Forum for developers on Sun Cobalt Networks products <cobalt-developers.list.cobalt.com>
I use following scripts to migrate DNS records from any DNS server:
getdomain:
#!/bin/sh
SUCCESS=0;
DOMAIN=$1;
NAMESERVERS=`dig -t NS $DOMAIN | grep 'IN NS' | sed 's/.*NS //'`
if test $? != 0; then
echo "Unable to fetch domain";
exit 1;
fi
for NAMESERVER in $NAMESERVERS; do
if test $SUCCESS = 0; then
RESULT=`named-xfer -f /tmp/$DOMAIN -z $DOMAIN $NAMESERVER 2>
/dev/null`;
fi
if test $? = 4; then
SUCCESS=1;
fi
done
DOMAINCONTENTS=`cat /tmp/$DOMAIN 2>/dev/null`;
if test $? != 0; then
echo "Unable to fetch domain";
exit 1;
fi
./ipdomain $DOMAIN;
rm /tmp/$DOMAIN
ipdomain:
#!/usr/bin/perl
my $DOMAIN=$ARGV[0];
my $DOMAINCONTENTS="cat /tmp/$DOMAIN";
my $NSHOSTM=`$DOMAINCONTENTS| grep SOA | sed 's/.*SOA//' | tr "\\t" " " |
sed 's/ *//'`;
my $NS1=$NSHOSTM;
$NS1=~ s/ .*//;
$NS1=~ s/(.*)\./\1/;
$NS1=lc($NS1);
chomp($NS1);
my $HOSTMASTER=$NSHOSTM;
$HOSTMASTER=~ s/.* (.*) .*/\1/;
$HOSTMASTER=~ s/(.*)\./\1/;
$HOSTMASTER=lc($HOSTMASTER);
$HOSTMASTER=~ s/\./@/;
chomp($HOSTMASTER);
#print "ns1: $NS1\n";
#print "hostmaster: $HOSTMASTER\n";
my $SOAVALUES=`$DOMAINCONTENTS | tr "\n\t" " "`;
$SOAVALUES=~ s/.*\((.*)\).*/\1/;
$SOAVALUES=~ s/ *[0-9]+ ([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+).*/\1:\2:\3:\4/;
#print "soavalues: $SOAVALUES\n";
my $soadetect=0;
open(ZONE, "/tmp/$DOMAIN");
while (<ZONE>) {
if($soadetect) {
$soadetect=0;
next;
}
chomp($_);
if (!/^;/) {
if (/^\$ORIGIN/) {
s/\$ORIGIN (.*)\./\1/;
$zone=lc($_);
# print "Zone: $zone\n";
} elsif (/.*IN\tSOA\t*.*/) {
s/(.*)\t[0-9]+.*/\1/;
$zone=lc($_.".".$zone);
$soadetect=1;
# print "Zone: $zone\n";
next;
} elsif (/.*IN\tNS\t.*/) {
if (!/^\t/) { # STILL HAVE TO DO !!!
$host=$_;
$host=~ s/IN\tA\t.*//;
$host=~ s/(.*)\t+[0-9]+.*/\1/;
$host=lc($host);
} else {
$ns=$_;
$ns=~ s/.*IN\tNS\t//;
$ns=~ s/(.+)\./\1/;
$ns=lc($ns);
if ($ns ne $NS1) {
if($NS2 eq "") {
$NS2=$ns;
} else {
$NS2=$NS2."+".$ns;
}
}
}
} elsif (/.*IN\tCNAME\t.*/) {
if (!/^\t/) {
$host=$_;
$host=~ s/IN\tCNAME\t.*//;
$host=~ s/(.*)\t+[0-9]+.*/\1/;
$host=lc($host);
} else {
$host="-";
}
$chost=$_;
$chost=~ s/.*IN\tCNAME\t//;
$chost=~ s/\..+//;
$czone=$_;
$czone=~ s/.*IN\tCNAME\t//;
$czone=~ s/$chost\.(.*)\./\1/;
print "cname $host $zone $chost $czone\n";
} elsif (/.*IN\tMX\t.*/) {
if (!/^\t/) {
$host=$_;
$host=~ s/IN\tA\t.*//;
$host=~ s/(.*)\t+[0-9]+.*/\1/;
$host=lc($host);
} else {
$host="-";
}
$priority=$_;
$priority=~ s/.*IN\tMX\t//;
$priority=~ s/([0-9]+) .*/\1/;
if ($priority eq "0") {
$priority="Very-High";
} elsif ($priority > 0 && $priority < 51) {
$priority="High";
} elsif ($priority > 50 && $priority <= 100) {
$priority="Low";
} elsif ($priority > 100) {
$priority="Very-Low";
}
$mailhost=$_;
$mailhost=~ s/.*IN\tMX\t[0-9]+ //;
$mailhost=~ s/(.+)\./\1/;
print "mx $host $zone $priority $mailhost\n";
} elsif (/.*IN\tA\t.*/) {
if (!/^\t/) {
$host=$_;
$host=~ s/IN\tA\t.*//;
$host=~ s/(.*)\t+[0-9]+.*/\1/;
$host=lc($host);
} else {
$host="-";
}
$ip=$_;
$ip=~ s/.*IN\tA\t//;
print "a $host $zone $ip 24\n";
} else {
print lc($_)."\n";
}
}
}
close ZONE;
$NS1="<your nameserver hostname1>";
$NS2="<your nameserver hostname2>";
$HOSTMASTER="hostmaster\@<domainname of nameserver>";
print "soa - $DOMAIN $NS1:$NS2:$HOSTMASTER:$SOAVALUES -\n";
----- Original Message -----
From: "Mike Moses" <mmoses@xxxxxxxxxxxxxxxx>
To: <cobalt-developers@xxxxxxxxxxxxxxx>
Sent: Thursday, March 07, 2002 14:05
Subject: [cobalt-developers] Importing DNS Records
> Has any one imported dns records into a Raq3 from a Windows 2000 dns
> machine?
> The text files that contain the records are all avaliable and are in
> standard form.
>
> Thanks
>
> Mike Moses, MCT, MCP, CCA
> Divisional President and Technical Controller
> OneWorld ISP Corporation
> http://www.oneworldhost.com
> 902-852-4381
>
>
> _______________________________________________
> cobalt-developers mailing list
> cobalt-developers@xxxxxxxxxxxxxxx
> http://list.cobalt.com/mailman/listinfo/cobalt-developers
>