Skip to content

Instantly share code, notes, and snippets.

@markuskont
Last active April 15, 2016 10:49
Show Gist options
  • Save markuskont/912fb61e94a3da0938c92358bb17dd4a to your computer and use it in GitHub Desktop.
Save markuskont/912fb61e94a3da0938c92358bb17dd4a to your computer and use it in GitHub Desktop.
Generate IPv4 reverse DNS records for Bind
#!/usr/bin/env perl
sub populateArrayFromFile {
my ($filename) = @_;
open FILE, $filename || die "Cannot open file ".$filename." for read";
@lines=<FILE>;
close FILE;
return @lines;
}
#Main
foreach my $filename (@ARGV) {
my @newlines = ();
my @lines = populateArrayFromFile($filename);
foreach $line (@lines) {
if ($line =~ m/\d{1,3}\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\S*\s+(\S+)/) {
print "$3.$2.$1 IN PTR $4.", "\n"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment