[nsp] Script to check interface IPs for reverse DNS records
John Kristoff
jtk at northwestern.edu
Thu Jan 8 20:34:26 EST 2004
Here is something else I thought someone may find useful. Below is a
script that will check interface IPs for in-addr.arpa records. Pass one
or more stored config files on the command line. This does not support
IPv6, but it should be relatively trivial to do that with minor changes.
Perhaps you can tell I'm playing the role of network janitor lately? :-)
I hereby place this script in the public domain. Warning, script lines
may wrap in your email client:
#!/usr/bin/perl -wT
use strict;
$| = 1;
#
# ios-ipnames - check for reverse address records on interface IPs
#
# usage: ios-ipnames router-config-file(s)
use Socket;
my $host = "";
my $interface = "";
while (defined(my $line = <>)) {
chomp $line;
if ($line =~ /^hostname \S+$/) { ($host) = $line =~ /^hostname (\S+)$/; }
if ($line =~ /^interface \S+$/) {
($interface) = $line =~ /^interface (\S+)$/;
next;
}
if ($line =~ /^ ip address \d+\.\d+\.\d+\.\d+ \S+.*$/) {
my ($ip) = $line =~ /^ ip address (\d+\.\d+\.\d+\.\d+) \S+.*$/;
my $name = "";
$name = gethostbyaddr(inet_aton($ip), AF_INET)
or $name = "lookup failed";
print "$host:$interface:$ip:$name\n";
}
}
# end script
John
More information about the cisco-nsp
mailing list