diff -burNx *CVS* /usr/home/dnsadmin/work/Makefile work/Makefile --- /usr/home/dnsadmin/work/Makefile Tue Jun 16 16:09:17 1998 +++ work/Makefile Mon Jan 31 03:31:03 2000 @@ -7,6 +7,7 @@ # DB = DNS-Datenbank +DB_full = Netz-Datenbank DB_local = localhost-Datenbank DBfiles = db.fh-regensburg.de \ db.194.95.104 \ diff -burNx *CVS* /usr/home/dnsadmin/work/db2db work/db2db --- /usr/home/dnsadmin/work/db2db Mon Jul 6 11:39:05 1998 +++ work/db2db Wed Feb 9 23:47:37 2000 @@ -3,7 +3,50 @@ # $Id: db2db,v 1.3 1998/07/06 09:38:38 dnsadmin Exp dnsadmin $ # +# Computes IPv6 interface IDs from the Ethernet MAC address +# See: RFC 2373, IEEE EUI-64 standard +sub mac2if +{ + local $mac=@_[0]; + local @mac, @eui64, @if, $if, @hif; + + die "Usage: $0 xx:xx:xx:xx:xx:xx\n" + if ($mac eq ""); + + @mac = ( $mac =~ /^(..):(..):(..):(..):(..):(..)$/); + + die "Usage: $0 xx:xx:xx:xx:xx:xx\n" + if ! @mac; + + # Insert 0xfffe in the middle, to generate EUI64 - see RFC 2373 + @eui64 = @mac; + splice(@eui64, 3, 0, sprintf("%02x", 0xff), sprintf("%02x", 0xfe)); + + #print "MAC: ", join(":", @mac), "\n"; + #print "EUI64: ", join(":", @eui64), "\n"; + + @if=@eui64; + + # Per RFC 2373, flip global flag + # (per Ignatios , there are non-global ethernet ids!) + $if[0] = sprintf("%02x", hex($if[0]) ^ 0x02); + + @hif=@if; + undef $if; + $if.=shift(@hif); $if.=shift(@hif); $if .= ":"; + $if.=shift(@hif); $if.=shift(@hif); $if .= ":"; + $if.=shift(@hif); $if.=shift(@hif); $if .= ":"; + $if.=shift(@hif); $if.=shift(@hif); + #print "ifID: ", join(":", @if), "\n"; + return "$if"; +} + + +########################################################################### +# MAIN +########################################################################### + if ( $#ARGV < 3 ){ print STDERR "Usage: $0 domain SOA-template serial-file DB-file\n"; print STDERR "or: $0 domain SOA-template serial-file DB-file IP-Net\n"; @@ -13,12 +56,15 @@ $SOA_f = $ARGV[1]; # SOA-file $serial_f = $ARGV[2]; # File with serial in it $DB_f = $ARGV[3]; # File with Datebase in it +$DB_f2 = "Vollstaendige-Datenbank"; # File with fullDatebase in it, for MAC etc. +$V6_prefix= "0000:0000:0000:0000:"; # vorerst lokal $ipnet = $ARGV[4]; # Subnet-Address (IP) #print "domain: $domain\n"; #print "SOA_f: $SOA_f\n"; #print "serial_f: $serial_f\n"; #print "DB_f: $DB_f\n"; +#print "DB_f2: $DB_f2\n"; #print "ipnet: $ipnet\n"; @@ -78,6 +124,20 @@ # +# Read in full DB for MACs +# +open (FULL, "$DB_f2") + or die "Can't read $DB_f2: $!\n"; +while() { + chomp; + @a=split(/;/); + $mac{$a[0]} = $a[3]; # MAC address + $net{$a[0]} = $a[4]; # ETHERNET, 100BaseT, SERIAL, ... + $betreuer{$a[0]} = $a[8]; +} +close(FULL); + +# # The hosts themselves # open(DB,"$DB_f") @@ -142,11 +202,25 @@ $loaded=1; } + # For now, only enter AAAA records for Ethernet devices + #print "Name=$H{'Name'}, net=$net{$H{'Name'}}, mac=$mac{$H{'Name'}}\n"; + if ($net{$H{'Name'}} eq "ETHERNET" or + $net{$H{'Name'}} eq "100BaseT") { + if ($mac{$H{'Name'}} ne "") { + $H{'IP6-Adresse'} = "$V6_prefix" . mac2if($mac{$H{'Name'}}); + }else{ + print "No MAC address for $H{'Name'} (=> $betreuer{$H{'Name'}})!\n"; + $H{'IP6-Adresse'} = ""; + } + } + #print "\tIP6-Adr = $H{'IP6-Adresse'}\n"; + if($loaded){ if(!$ipnet){ # Forward-Mapping # printf OUT "%-20s \t\tIN A $H{'IP-Adresse'}\n",$H{'Name'} if $H{'IP-Adresse'} ne "" and $H{'Name'} ne ""; + printf OUT "%-20s \t\tIN AAAA $H{'IP6-Adresse'}\n",$H{'Name'} if $H{'IP6-Adresse'} ne "" and $H{'Name'} ne ""; printf OUT "%-20s \t\tIN CNAME $H{'Name'}\n",$H{'Alias'} if $H{'Alias'} and $H{'Name'} ne ""; printf OUT "%-20s \t\tIN HINFO $H{'Rechnertyp'} $H{'Betriebssystem'}\n", diff -burNx *CVS* /usr/home/dnsadmin/work/grabdb work/grabdb --- /usr/home/dnsadmin/work/grabdb Wed Jul 28 14:36:14 1999 +++ work/grabdb Mon Jan 31 04:05:43 2000 @@ -9,9 +9,11 @@ DST_DB=./DNS-Datenbank SRC_DB=$DST_DB.incoming +DST_DB2=./Vollstaendige-Datenbank +SRC_DB2=$DST_DB2.incoming -cd $HOME/work +cd $HOME/work/dns/work if [ -f "$SRC_DB.lock" ]; then echo 'DNS-Transfer in Progress\c' @@ -28,8 +30,14 @@ if ping rfhnt8001 5 2>&1 >/dev/null then - echo $$ >>$SRC_DB.lock + : Irgendwer meinte dass da oben kein '!' stehen darf... +else + echo "DB-Server is down, can't perform DNS-update." + exit 1 +fi +echo $$ >>$SRC_DB.lock + # Erste Zeile (
) und ^Ms entfernen:
 	 ./dump-access-db > blah
 	tail +2 blah > blub
@@ -37,24 +45,48 @@
 	rm -f blah
 	rm -f blub
 
-	diff $DST_DB $SRC_DB >$SRC_DB.diff
+	# Bis die DNS-Datenbank die MAC-Adressen und Interface-Arten
+	# enthaelt, vollstaendige Datenbank (SRC_DB2) konsultieren
+	# Erste Zeile (
) und ^Ms entfernen:
+	./dump-db >blah
+	tail +2 blah > blub		# NFC warum da +2 noetig sind ... - HF
+	sed -e 's/.$//g' blub > $SRC_DB2
+	rm -f blah
+	rm -f blub
 
+
 	if tail -1 $SRC_DB | grep '^#EOF#$' 2>&1 >/dev/null
 	then
 		: Doofes solaris if kann kein '!'
 	else
 		echo ""
-		echo 'NT hat unvollstaendige Datei geliefert!'
+		echo "NT hat unvollstaendige Datei $SRC_DB geliefert!"
+		echo ""
+		echo "*** DNS updated NOT successful!!! ***"
+
+		# rm -f $SRC_DB
+		rm $SRC_DB.lock
+
+		exit 1
+	fi
+
+	if tail -1 $SRC_DB2 | grep '^$' 2>&1 >/dev/null
+	then
+		: Doofes solaris if kann kein '!'
+	else
+		echo ""
+		echo "NT hat unvollstaendige Datei $SRC_DB2 geliefert!"
 		echo ""
 		echo "*** DNS updated NOT successful!!! ***"
 
 		rm -f $SRC_DB
-		rm $SRC_DB.diff
+		rm -f $SRC_DB2
 		rm $SRC_DB.lock
 
 		exit 1
 	fi
 
+	diff $DST_DB $SRC_DB >$SRC_DB.diff
 	if [ -s $SRC_DB.diff ]
 	then
 		echo 'Unterschiede (< alt, > neu):'
@@ -66,9 +98,11 @@
 		mv $SRC_DB $DST_DB
 		touch $DST_DB
 	
+		mv $SRC_DB2 $DST_DB2
+	
 		ci -l -m"$0: `date`" $DST_DB
 		cd `dirname $DST_DB`
-		if make install 
+		if make #HF# install 
 		then
 			echo ""
 			echo "-> DNS updated successfully."
@@ -81,6 +115,3 @@
 	fi
 	rm $SRC_DB.diff
 	rm $SRC_DB.lock
-else
-	echo "DB-Server is down, can't perform DNS-update."
-fi
--- /dev/null	Wed Feb  9 23:45:04 2000
+++ work/dump-db	Mon Jan 31 03:29:55 2000
@@ -0,0 +1,35 @@
+#!/soft/local/bin/perl5
+#
+# Vollstaendige Datenbank dumpen
+
+use Socket;
+require "tcp.pl";
+
+$SERVER=rfhnt8001;
+
+if (open_TCP(F, $SERVER, 80) == undef) {
+	print "Fehler beim Verbindungsaufbau zu Server $SERVER\n";
+	exit(-1);
+}
+
+print F "POST /db/fhliste.IDC HTTP/1.0\n";
+print F "Content-type: application/x-www-form-urlencoded\n";
+print F "Content-length: 12\n";
+print F "\n";
+print F "LISTE=+LISTE\n\n";
+
+
+$returnline=;
+
+# print "$returnline";
+
+while(=~ m/^(\S+):\s(.+)/) {
+#	print "$1: $2";
+}
+
+# Body lesen.
+print while ();
+
+
+close(F);
+