fix_negative_ttl

This commit is contained in:
hjp 2012-11-15 11:57:42 +00:00
parent e80dfbc808
commit abf8fdc9ba
1 changed files with 27 additions and 0 deletions

27
dns/fix_negative_ttl Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/perl
use warnings;
use strict;
use autodie;
for my $zonefile (@ARGV) {
open my $in, '<', $zonefile;
open my $out, '>', "$zonefile.$$";
while (<$in>) {
# @ SOA ns1.wsr.ac.at. hostmaster.wsr.ac.at. 1957 14400 3600 604800 86400
if ( my ($prefix, $master, $rp, $serial, $refresh, $retry, $expire, $negttl)
= m/(.*)SOA\s+(\S+)\s+(\S+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)\s(\d+)/
) {
# maximum time recommended by RFC 2308, also enforced by
# BIND (by default).
if ($negttl >= 3 * 3600) {
$negttl = 3600;
$serial++;
}
print $out "${prefix}SOA\t$master $rp $serial $refresh $retry $expire $negttl\n";
} else {
print $out $_;
}
}
rename "$zonefile.$$", $zonefile;
}