NAME
Net::DNS - Perl interface to the DNS resolver
DESCRIPTION
Net::DNS is a collection of Perl modules to interface with the Domain Name System (DNS) resolver. It allows the programmer to perform queries that are beyond the capabilities of gethostbyname
and gethostbyaddr
.
Resolver Objects
A resolver object is an instance of the Net::DNS::Resolver
class. A program can have multiple resolver objects, each maintaining its own state information such as the nameservers to be queried, whether recursion is desired, etc.
Packet Objects
Net::DNS::Resolver
queries return Net::DNS::Packet
objects. Packet objects have five sections:
The header section, a
Net::DNS::Header
object.The question section, a list of
Net::DNS::Question
objects.The answer section, a list of
Net::DNS::RR
objects.The authority section, a list of
Net::DNS::RR
objects.The additional section, a list of
Net::DNS::RR
objects.
Header Objects
Net::DNS::Header
objects represent the header section of a DNS packet.
Question Objects
Net::DNS::Question
objects represent the query section of a DNS packet.
RR Objects
Net::DNS::RR
is the base class for DNS resource record (RR) objects in the answer, authority, and additional sections of a DNS packet.
EXAMPLES
These examples show how to use the DNS modules:
# Look up a host's addresses.
use Net::DNS::Resolver;
$res = new Net::DNS::Resolver;
$query = $res->search("foo.bar.com");
foreach $record ($query->answer) {
print $record->address, "\n";
}
# Find the nameservers for a domain.
use Net::DNS::Resolver;
$res = new Net::DNS::Resolver;
$query = $res->query("foo.com", "NS");
foreach $nameserver ($query->answer) {
print $nameserver->nsdname, "\n";
}
# Find the MX records for a domain.
use Net::DNS::Resolver;
$res = new Net::DNS::Resolver;
$query = $res->query("foo.com", "MX");
foreach $mxhost ($query->answer) {
print $mxhost->preference, " ", $mxhost->exchange, "\n";
}
# Print a domain's SOA record in zone file format.
use Net::DNS::Resolver;
$res = new Net::DNS::Resolver;
$query = $res->query("foo.com", "SOA");
($query->answer)[0]->print;
BUGS
TCP transfers are not yet implemented. Zone transfers won't be possible until they are.
COPYRIGHT
Copyright (c) 1997 Michael Fuhr. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
perl(1), Net::DNS::Resolver, Net::DNS::Packet, Net::DNS::Header, Net::DNS::Question, Net::DNS::RR, RFC 1035