DNS-Robot
view release on metacpan or search on metacpan
lib/DNS/Robot.pm view on Meta::CPAN
# DKIM record check
my $dkim = $dr->dkim_check(domain => 'gmail.com', selector => 'google');
print "Found: $dkim->{found}\n";
# DMARC record check
my $dmarc = $dr->dmarc_check(domain => 'gmail.com');
print "Policy: $dmarc->{policy}\n";
# MX records
my $mx = $dr->mx_lookup(domain => 'gmail.com');
for my $rec (@{ $mx->{mxRecords} }) {
print "$rec->{priority} $rec->{exchange}\n";
}
# NS records
my $ns = $dr->ns_lookup(domain => 'google.com');
print "$_->{nameserver}\n" for @{ $ns->{nameservers} };
# IP geolocation
my $ip = $dr->ip_lookup(ip => '8.8.8.8');
print "Location: $ip->{city}, $ip->{country}\n";
# HTTP headers
my $headers = $dr->http_headers(url => 'https://example.com');
print "Status: $headers->{statusCode}\n";
# Port check
my $port = $dr->port_check(host => 'example.com', port => 443);
print "Port 443 is $port->{status}\n";
=head1 DESCRIPTION
DNS::Robot is a Perl client for the free DNS and network tools API at
L<https://dnsrobot.net>. It provides access to 11 tools for DNS lookups,
WHOIS queries, SSL certificate checks, email authentication (SPF, DKIM,
DMARC), and more.
No API key is required. The module uses only core Perl modules (HTTP::Tiny,
JSON::PP, Carp) and has zero external dependencies.
=head1 CONSTRUCTOR
=head2 new
my $dr = DNS::Robot->new(%options);
Creates a new DNS::Robot client. Options:
=over 4
=item * C<base_url> â API base URL (default: C<https://dnsrobot.net/api>)
=item * C<user_agent> â User-Agent header (default: C<DNS-Robot-Perl/$VERSION>)
=item * C<timeout> â HTTP timeout in seconds (default: 30)
=back
=head1 METHODS
All methods return a hashref of the decoded JSON response. On HTTP errors,
they C<die> with a descriptive message.
=head2 dns_lookup
my $result = $dr->dns_lookup(
domain => 'example.com', # required
record_type => 'A', # optional, default: A
dns_server => '8.8.8.8', # optional, default: 8.8.8.8
);
Performs a DNS lookup. Supports A, AAAA, MX, TXT, CNAME, NS, SOA, and other
record types.
See also: L<https://dnsrobot.net/dns-lookup>
=head2 whois_lookup
my $result = $dr->whois_lookup(domain => 'example.com');
Retrieves WHOIS registration data including registrar, dates, nameservers,
and domain status.
See also: L<https://dnsrobot.net/whois-lookup>
=head2 ssl_check
my $result = $dr->ssl_check(domain => 'github.com');
Checks the SSL/TLS certificate for a domain, returning issuer, validity
dates, certificate chain, and subject alternative names.
See also: L<https://dnsrobot.net/ssl-checker>
=head2 spf_check
my $result = $dr->spf_check(domain => 'gmail.com');
Validates the SPF (Sender Policy Framework) record, returning the raw
record, parsed mechanisms, grade, and any warnings.
See also: L<https://dnsrobot.net/spf-checker>
=head2 dkim_check
my $result = $dr->dkim_check(
domain => 'gmail.com', # required
selector => 'google', # optional
);
Checks DKIM (DomainKeys Identified Mail) records. If no selector is given,
common selectors are tried automatically.
See also: L<https://dnsrobot.net/dkim-checker>
=head2 dmarc_check
my $result = $dr->dmarc_check(domain => 'gmail.com');
Validates the DMARC record, returning the policy, subdomain policy, grade,
and any warnings.
( run in 1.091 second using v1.01-cache-2.11-cpan-d06a3f9ecfd )