Created
April 6, 2011 11:32
-
-
Save EdwardIII/905506 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use File::Slurp qw(read_file); | |
my @zone_files = glob('/var/named/*.db'); | |
my $out_dir = '/home/datastore/newzones/'; # always include trailing slash | |
use Net::DNS::ZoneFile::Fast; | |
use Data::Dumper; | |
use File::Basename qw(basename); | |
foreach my $zone_file (@zone_files){ | |
my $zone_text = read_file($zone_file); | |
my $rrs = Net::DNS::ZoneFile::Fast::parse($zone_text); | |
$zone_file = basename($zone_file); | |
open(my $fh, '>', $out_dir . $zone_file) or die "Couldn't open $out_dir$zone_file: $!"; | |
foreach my $rr (@$rrs){ | |
$rr->ttl(60) unless ($rr->type eq 'NS' || $rr->type eq 'SOA'); | |
print $fh $rr->string . "\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment