NAME
DNS::Robot - Perl client for the DNS Robot API (dnsrobot.net)
SYNOPSIS
use DNS::Robot;
my $dr = DNS::Robot->new();
# DNS lookup
my $dns = $dr->dns_lookup(domain => 'example.com', record_type => 'A');
print "IP: $_\n" for @{ $dns->{resolvedIPs} };
# WHOIS lookup
my $whois = $dr->whois_lookup(domain => 'example.com');
print "Registrar: $whois->{registrar}{name}\n";
# SSL certificate check
my $ssl = $dr->ssl_check(domain => 'github.com');
print "Valid: $ssl->{leafCertificate}{isValid}\n";
print "Expires in: $ssl->{leafCertificate}{daysToExpire} days\n";
# SPF record check
my $spf = $dr->spf_check(domain => 'gmail.com');
print "Grade: $spf->{grade} ($spf->{score}/100)\n";
# 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";
DESCRIPTION
DNS::Robot is a Perl client for the free DNS and network tools API at 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.
CONSTRUCTOR
new
my $dr = DNS::Robot->new(%options);
Creates a new DNS::Robot client. Options:
base_url— API base URL (default:https://dnsrobot.net/api)user_agent— User-Agent header (default:DNS-Robot-Perl/$VERSION)timeout— HTTP timeout in seconds (default: 30)
METHODS
All methods return a hashref of the decoded JSON response. On HTTP errors, they die with a descriptive message.
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: https://dnsrobot.net/dns-lookup
whois_lookup
my $result = $dr->whois_lookup(domain => 'example.com');
Retrieves WHOIS registration data including registrar, dates, nameservers, and domain status.
See also: https://dnsrobot.net/whois-lookup
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: https://dnsrobot.net/ssl-checker
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: https://dnsrobot.net/spf-checker
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: https://dnsrobot.net/dkim-checker
dmarc_check
my $result = $dr->dmarc_check(domain => 'gmail.com');
Validates the DMARC record, returning the policy, subdomain policy, grade, and any warnings.
See also: https://dnsrobot.net/dmarc-checker
mx_lookup
my $result = $dr->mx_lookup(domain => 'gmail.com');
Retrieves MX records with priority, exchange hostnames, resolved IP addresses, and provider detection.
See also: https://dnsrobot.net/mx-lookup
ns_lookup
my $result = $dr->ns_lookup(domain => 'google.com');
Retrieves nameserver records with response times and resolved IP addresses.
See also: https://dnsrobot.net/ns-lookup
ip_lookup
my $result = $dr->ip_lookup(ip => '8.8.8.8');
Looks up geolocation data for an IP address, including city, country, ISP, organization, and AS number.
See also: https://dnsrobot.net/ip-lookup
http_headers
my $result = $dr->http_headers(url => 'https://example.com');
Fetches and analyzes HTTP response headers, including security grade and individual header details.
See also: https://dnsrobot.net/http-headers
port_check
my $result = $dr->port_check(
host => 'example.com', # required
port => 443, # required (single port)
);
Checks whether a single TCP port is open or closed on the given host.
See also: https://dnsrobot.net/port-checker
ERROR HANDLING
All methods die on failure. Wrap calls in eval or use Try::Tiny:
use Try::Tiny;
try {
my $result = $dr->dns_lookup(domain => 'example.com');
# process $result
} catch {
warn "DNS lookup failed: $_";
};
SEE ALSO
https://dnsrobot.net — DNS Robot: 53 free online DNS and network tools
https://github.com/dnsrobot/dns-robot-cli — Source repository
AUTHOR
DNS Robot <cpan@dnsrobot.net>
LICENSE
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 218:
Non-ASCII character seen before =encoding in '—'. Assuming UTF-8