Last active
April 15, 2016 10:49
-
-
Save markuskont/912fb61e94a3da0938c92358bb17dd4a to your computer and use it in GitHub Desktop.
Generate IPv4 reverse DNS records for Bind
This file contains hidden or 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 | |
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