Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DNS/RDNS Script 1

Status
Not open for further replies.

ericwoodland

Technical User
Jan 23, 2008
4
0
0
US
Hello Everyone-

Newbie here! I'm pretty new to scripting in general, but figure Perl is the closest match in accomplishing the following task:

(List of Hostnames)
=> Perform NSLOOKUP on each line item & log.
=> Perform a Reverse NSLOOKUP query (based on the IPs provided by the forward lookup) & log.
=> Identify which forward/reverse entries do not match and provide a list.

The commands used would be NSLOOKUP %Hostname%, NSLOOKUP %IP%

I get the logic part, just don't know how to make it happen!

Thanks,

-=Woody=-
 
well just to give you something to get you started

my @list = qw(
for my $site (@list) {
my @output = `nslookup $site`;
for my $tmp (@output) {
if ($tmp =~ /Address/) {
my @data = split /\s+/, $tmp;
my @output2 = `nslookup $data[1]`;
}
}
}

Not tested, verified, double checked, spell checked, or even glanced at more than once !!
You might look into using Net::Nslookup instead of doing system calls to nslookup.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Travs-

Thanks for the starter. The design seems to work. Now, to take it two steps further. Gather input from a txt file having each entry on a single line & append any exceptions to a log file with a date format like (RDNS-012308). I'll be taking a Perl class in a month, so I'm enjoying all the info prior to!

Thanks-

-=Woody=-
 
input files are easy
open(FILE, "</path/to/file") or die "can't open /path/to/file:$!\n";
my @list = <FILE>;
chomp @list;
close FILE;


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Travs-

How would the output file work?

Thanks-

-=Woody=-
 
open(OUT, ">/path/to/file") or die "can't open /path/to/file:$!\n";

print OUT "Blah blah blah\n";

close OUT


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top