simple/dns/query

20 lines
398 B
Plaintext
Raw Permalink Normal View History

2008-04-28 09:47:50 +02:00
#!/usr/bin/perl -w
use strict;
use Net::DNS;
sub usage {
print STDERR "Usage: $0 domainname type nameserver\n" unless (@ARGV == 2);
exit(1);
}
usage() unless (@ARGV == 3);
my $res = new Net::DNS::Resolver;
$res->nameservers($ARGV[2]);
my $answer = $res->query($ARGV[0], $ARGV[1]);
if ($answer) {
$answer->print;
} else {
print STDERR "query failed: ", $res->errorstring, "\n";
}