Added dns-inc-serial to increment the serial number in a DNS zone file.

This commit is contained in:
hjp 2008-04-28 15:57:05 +00:00
parent 070a6da94b
commit 7d35c95bc5
1 changed files with 23 additions and 0 deletions

23
dns/dns-inc-serial Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/perl
use warnings;
use strict;
# Idea for improvement:
# take maximum of serial from file and from all authoritative nameservers,
# then increment by one.
for my $f (@ARGV) {
rename $f, "$f.old" || die "cannot rename $f to $f.old: $!";
open (my $in, '<', "$f.old") or die "cannot open $f.old: $!";
open (my $out, '>', "$f") or die "cannot open $f: $!";
while (<$in>) {
if (/(.*\bSOA\b.*?)(\d+)( \d+ \d+ \d+ \d+)/) {
my $serial = $2;
$serial++;
print $out "$1$serial$3\n";
} else {
print $out $_;
}
}
close($out) or die "cannot close $out";
}