3 # Extract zones and their nameservers from tinydns-data file(s) and
4 # send DNS "NOTIFY" requests to nameservers listed in notify-list
5 # The file "notify-list" must contain one nameserver per line
7 # Written 2001-02-20 by Andrew Pam <xanni@sericyb.com.au>
8 # Modified 2002-08-22 to support records that define nameserver addresses
9 # Modified 2002-08-30 to support "." records as well as "&" records
10 # Copyright (c) 2001-02 Serious Cybernetics <http://www.sericyb.com.au/>
11 # Partially inspired by dnsnotify by Jos Backus and James Raftery
12 # Distribute and modify freely, providing attribution is preserved
17 my @self = split /\//, $0;
18 die "Usage: $self[-1] zonefile [...]\n" unless $#ARGV >= 0;
21 open(LIST, "notify-list") or die "Can't open notify-list file\n";
25 my $server = inet_aton $_ or (warn "$_ is not a valid server", next);
26 $notify{$server} = "";
33 my ($zone, $ip, $server) = /^[\&\.]([^:]*):([^:]*):([^:]*)/ or next;
34 $server = inet_aton ($ip || $server) or next;
35 $notify{$server} .= "$zone " if defined $notify{$server};
38 my $res = new Net::DNS::Resolver;
40 foreach $s (keys %notify)
42 next unless $_ = $notify{$s};
43 foreach (my @zone = split)
45 my $packet = new Net::DNS::Packet($_, "SOA", "IN");
46 die unless defined $packet;
47 ($packet->header)->opcode("NS_NOTIFY_OP");
48 ($packet->header)->rd(0);
49 ($packet->header)->aa(1);
50 my $server = inet_ntoa($s);
51 $res->nameservers($server);
52 $reply = $res->send($packet);
54 { print "Received NOTIFY answer for $_ from " . $reply->answerfrom . "\n"; }
56 { warn "\$res->send indicates NOTIFY error for $server\n"; }