Created
March 19, 2013 10:10
-
-
Save neingeist/5194968 to your computer and use it in GitHub Desktop.
Check PTR for every IP in the given block.
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/perl | |
# Check PTR for every IP in the given block. | |
use 5.010; | |
use strict; | |
use warnings; | |
use Readonly; | |
use Net::Netmask; | |
use Socket; | |
Readonly my $BLOCK => '46.4.238.160/28'; | |
my $block = Net::Netmask->new($BLOCK); | |
for my $ip ($block->enumerate()) { | |
my $ptr_name = gethostbyaddr inet_aton($ip), AF_INET; | |
my $ptr_ip = inet_ntoa(scalar gethostbyname $ptr_name); | |
if ($ip eq $ptr_ip) { | |
say "OK: $ip resolves to $ptr_name"; | |
} else { | |
say "W: $ip resolves to $ptr_name and it does NOT resolve back, but to $ptr_ip instead."; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment