Rust SDK · Feature

ASN & DNS Lookups in Rust

Resolve the network and DNS layer behind an IP or domain: which autonomous system owns an address, who registered a domain, what a host's PTR record is, and which mail servers a domain uses — all from the same client.

Trusted by thousands of businesses
Fast JSON API responses
Real-time validation
Simple integration, SDKs & examples
What it does

Network ownership and DNS in one client

Behind every IP and domain is a network and DNS layer that tells you who owns the address space, when a domain was registered, and how its mail and hostnames resolve. ip-api.io exposes ASN, WHOIS, reverse/forward DNS, and MX lookups through the same client, so you can enrich logs, verify ownership, and feed fraud rules without juggling separate DNS crates.

Prerequisites

1

Autonomous system with asn

Returns the ASN, owning organization, network range, and country for an IP — and whether it belongs to a datacenter. Nullable fields are Option<T>.

let client = Client::new(std::env::var("IP_API_IO_KEY")?);

let asn = client.asn("8.8.8.8").await?;

if let Some(number) = asn.asn {
    println!("{number}");          // 15169
}
if let Some(org) = &asn.organization {
    println!("{org}");             // "Google LLC"
}
println!("{}", asn.is_datacenter); // true
2

Domain registration with whois

WHOIS record for a domain: registrar, registration/expiry/update dates, name servers, status codes, and the raw WHOIS text.

let whois = client.whois("example.com").await?;

if let Some(registrar) = whois.registrar.as_ref().and_then(|r| r.name.as_ref()) {
    println!("{registrar}");
}
if let Some(registered_on) = &whois.registered_on {
    println!("{registered_on}"); // "1995-08-14"
}
println!("{:?}", whois.name_servers);
3

DNS with reverse_dns, forward_dns & mx_records

Resolve a PTR record, resolve a hostname to addresses, or list a domain's mail servers.

let rdns = client.reverse_dns("8.8.8.8").await?;
if let Some(hostname) = &rdns.hostname {
    println!("{hostname}"); // "dns.google"
}

let fdns = client.forward_dns("dns.google").await?;
for record in &fdns.addresses {
    println!("{} {} {}", record.r#type, record.address, record.ttl); // "A" "8.8.8.8" 300
}

let mx = client.mx_records("example.com").await?;
for record in &mx.mx_records {
    println!("{} {} {}", record.priority, record.hostname, record.ttl);
}
Reference

Response reference

MethodReturnsKey fields
asn(ip)AsnLookupip, asn, organization, network, is_datacenter, country, country_code
whois(domain)Whoisdomain, registrar, registered_on, expires_on, updated_on, name_servers, status, raw
reverse_dns(ip)ReverseDnsip, hostname, ptr_record, ttl
forward_dns(hostname)ForwardDnshostname, addresses (each type, address, ttl)
mx_records(domain)MxLookupdomain, mx_records (each priority, hostname, ttl)
FAQ

Frequently asked questions

How do I find the ASN and owner of an IP in Rust?

Call client.asn(ip).await?. It returns the ASN number, owning organization, network range, country, and whether the IP belongs to a datacenter. Nullable fields are Option<T>.

How do I do a WHOIS lookup in Rust?

Use client.whois(domain).await?. It returns the registrar, registration/expiry/update dates, name servers, status codes, and the raw WHOIS text for a domain.

Can I do reverse and forward DNS lookups?

Yes. client.reverse_dns(ip).await? returns the PTR hostname for an IP, and client.forward_dns(hostname).await? resolves a hostname to its A/AAAA addresses. client.mx_records(domain).await? returns a domain's mail servers.

What's the difference between mx_records here and email validation?

mx_records(domain) returns the raw MX records (priority, hostname, ttl) for DNS inspection. The email validation methods use MX presence as one input to a deliverability verdict for a specific address.

Start building with the ip-api.io Rust SDK

Run cargo add ip-api-io, drop in your free API key, and ship in minutes — one async client for geolocation, fraud detection, and email validation.

Need support?

Explore how IP-API.io can enhance your security, provide robust bot protection, and improve IP geolocation accuracy for your applications.

Contact Support

Found a bug in the SDK?

The ip-api-io crate is open source. Open an issue or pull request on GitHub and we'll take a look.

Open on GitHub