Net-DNS

 view release on metacpan or  search on metacpan

lib/Net/DNS.pm  view on Meta::CPAN

=head2 Find the nameservers for a domain.

	use Net::DNS;
	my $res   = Net::DNS::Resolver->new;
	my $reply = $res->query( "example.com", "NS");
	die "query failed: ", $res->errorstring unless $reply;

	foreach $rr ( grep {$_->type eq "NS"} $reply->answer ) {
		print $rr->nsdname, "\n";
	}


=head2 Find the MX records for a domain.

	use Net::DNS;
	my $name = "example.com";
	my $res  = Net::DNS::Resolver->new;
	my @mx   = mx( $res, $name );

	foreach $rr (@mx) {
		print $rr->preference, "\t", $rr->exchange, "\n";
	}


=head2 Print domain SOA record in zone file format.

	use Net::DNS;
	my $res   = Net::DNS::Resolver->new;
	my $reply = $res->query( "example.com", "SOA" );
	die "query failed: ", $res->errorstring unless $reply;

	foreach my $rr ( $reply->answer ) {
		$rr->print;
	}


=head2 Perform a zone transfer and print all the records.

	use Net::DNS;
	my $res  = Net::DNS::Resolver->new(
		nameservers => ["a.iana-servers.net", "b.iana-servers.net"],
		tcp_timeout => 20
		);

	my @zone = $res->axfr("example.com");
	warn $res->errorstring if $res->errorstring;

	foreach $rr (@zone) {
		$rr->print;
	}


=head2 Perform a background query and print the reply.

	use Net::DNS;
	my $res    = Net::DNS::Resolver->new;
	$res->udp_timeout(10);
	$res->tcp_timeout(20);
	my $socket = $res->bgsend( "www.example.com", "AAAA" );

	while ( $res->bgbusy($socket) ) {
		# do some work here whilst awaiting the response
		# ...and some more here
	}

	my $packet = $res->bgread($socket);
	die "query failed: ", $res->errorstring unless $packet;

	$packet->print;


=head1 BUGS

Net::DNS is slow.

For other items to be fixed, or if you discover a bug in this
distribution please use the CPAN bug reporting system.


=head1 COPYRIGHT

Copyright (c)1997-2000 Michael Fuhr.

Portions Copyright (c)2002,2003 Chris Reinhardt.

Portions Copyright (c)2005 Olaf Kolkman (RIPE NCC)

Portions Copyright (c)2006 Olaf Kolkman (NLnet Labs)

Portions Copyright (c)2014 Dick Franks

All rights reserved.


=head1 LICENSE

Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted, provided
that the original copyright notices appear in all copies and that both
copyright notice and this permission notice appear in supporting
documentation, and that the name of the author not be used in advertising
or publicity pertaining to distribution of the software without specific
prior written permission.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.


=head1 AUTHOR INFORMATION

Net::DNS is maintained at NLnet Labs (www.nlnetlabs.nl) by Willem Toorop
and Dick Franks.

Between 2005 and 2012 Net::DNS was maintained by Olaf Kolkman.

Between 2002 and 2004 Net::DNS was maintained by Chris Reinhardt.



( run in 0.606 second using v1.01-cache-2.11-cpan-39bf76dae61 )