Reverse IP Check Script

Posted on Wednesday 29 October 2008

#!/usr/bin/perl

use Socket;

my %ips = qw/
  216.150.225.240 util.mg2.org
  216.150.225.241 erie.mg2.org
  216.150.225.242 ns03.mg2.org
  216.150.225.243 ns04.mg2.org
  216.150.225.244 mg2.org
  216.150.225.245 illegible.org
  216.150.225.246 ruht.ro
  216.150.225.247 uniquefreak.org
  216.150.225.248 praux.mg2.org
  216.150.225.249 nfs.mg2.org
  216.150.225.250 db.mg2.org
  216.150.225.251 mobjudgment.com
  216.150.225.252 ldap.mg2.org
  216.150.225.253 web.mg2.org
  216.150.225.254 mail.mg2.org
  /;

printf(
    "%-17s %-17s %-17s %-6s\n",
    "ip",
    "current value",
    "desired value", "update"
);
printf("----------------- ----------------- ----------------- ------\n");

foreach my $ip ( sort { $a cmp $b } keys %ips ) {
    $iaddr = inet_aton($ip);                       # or whatever address
    $current = gethostbyaddr( $iaddr, AF_INET );

    my $change = "Yes";
    if ( $current eq $ips{$ip} ) {
        $change = "No";
    }

    printf( "%-17s %-17s %-17s %-6s\n", $ip, $current, $ips{$ip}, $change );
}
Files: reverse_check.pl
[ ]

Leave a comment

(required)

(optional)


Information for comment users
Line and paragraph breaks are implemented automatically. Your e-mail address is never displayed. Please consider what you're posting.

Use the buttons below to customise your comment.