Help language development. Donate to The Perl Foundation

Net::DNS cpan:RBT last updated on 2020-06-12

Net: :DNS

A simple DNS resolver.

Note: If you are behind a firewall that blocks Google DNS, you will need to set DNS_TEST_HOST in your environment to pass the tests.

Example Usage

my $resolver =''); # google dns server

my @mx-ips = $resolver.lookup-mx('');

my @all = $resolver.lookup-ips('');
my @ipv4 = $resolver.lookup-ips('', :inet);
my @ipv6 = $resolver.lookup-ips('', :inet6);

my @dns-answers = $resolver.lookup('A', ''); # ("", "", ...)


Supported DNS Types

The return of a lookup is a list of classes. Which class depends on the request type.

The object returned will stringify to something useful, and will also provide attributes to access each piece of information that was returned.

Note that all of these classes also have a @.owner-name attribute. Normally this is the same as the domain name you did the lookup on.


DNS Server errors will produce a Failure response on lookup(), lookup-ips(), and lookup-mx() with an X::Net::DNS object.