Reverse DNS Lookup: How to Check PTR Records and What They Reveal

Blog / Networking basics

Reverse DNS Lookup: How to Check PTR Records and What They Reveal

A reverse DNS lookup takes an IP address and asks DNS for its hostname, which means querying the PTR record. On the command line, dig -x 1.1.1.1, nslookup 1.1.1.1 or host 1.1.1.1 will all do it. The hostname you get back can often hint at the carrier, the datacenter, or something like "this is a dynamic residential address". But the PTR is written by whoever manages the IP, and they can put anything in it, so treat it as a hint, never as proof.

How reverse DNS works: why is the IP written backwards?

Forward lookup is "domain name → IP" and uses A or AAAA records. Reverse lookup goes the other way, but DNS only understands domain names, so the IP is first converted into a special domain name, and then DNS looks up the PTR record for that name.

IPv4 lives under in-addr.arpa, with the four octets reversed. For example, 203.0.113.25 becomes:

25.113.0.203.in-addr.arpa.

The reason for reversing is that DNS delegates authority from right to left. In an IP address the network gets more specific from left to right (203. is a large block, .25 is a single host). Once reversed, the "large block" sits on the right, so authority can be delegated block by block to the address holder: a regional internet registry delegates a range under 203.in-addr.arpa to an ISP, and the ISP delegates further down to its customers.

IPv6 lives under ip6.arpa. The rule is to expand the address to the full 32 hex digits, make each digit its own label, and reverse the whole thing. For example, 2001:db8::1:

1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.

It is easy to drop a zero when doing this by hand, so let dig -x convert it for you. IPv6 address space is so large that many networks do not configure PTR at all, or only for fixed addresses such as routers and servers. If you first want to know whether you are on v4 or v6, see IPv4 vs IPv6: what's the difference, and how to check which one you're using.

How to check a PTR record: three commands and how to read the output

dig -x 1.1.1.1 +short
# one.one.one.one.

dig -x 8.8.8.8 +short
# dns.google.

Without +short you get the full response. Look at three parts:

  • status: NOERROR means the query succeeded. NXDOMAIN means the reverse name does not exist, which usually means no PTR is configured.
  • ANSWER SECTION: if a PTR record exists, it is here. One IP can have several PTR records, but most have just one.
  • AUTHORITY SECTION: when there is no answer, the SOA record here tells you who owns the reverse zone, which often points straight to the carrier or cloud provider's domain.

To see who the reverse zone is delegated to, query NS:

dig NS 113.0.203.in-addr.arpa +short

nslookup (built into Windows)

nslookup 8.8.8.8
# or specify the type explicitly
nslookup -q=ptr 8.8.8.8

The name = dns.google line in the output is the PTR result. If you see can't find ... Non-existent domain, there is no PTR.

host (the most concise)

host 1.1.1.1
# 1.1.1.1.in-addr.arpa domain name pointer one.one.one.one.

Batch lookups

To look up a batch of IPs from a log, generate a batch file and feed it to dig -f (ips.txt has one IP per line):

awk '{print "-x", $1, "+short"}' ips.txt > batch.txt
dig -f batch.txt

Batch queries add load to the other side's DNS servers. For large lists, work in batches with a pause in between.

What can a PTR hostname tell you?

To make their own operations easier, carriers and datacenters often write an address's purpose and location into the PTR. The table below shows common naming habits as examples of how to read them. It is not a statistical claim about any type of network.

Fragment in the hostname (examples)Possible meaningConfidence
dynamic, dyn, pool, dhcp, pppDynamic address pool for home broadband or mobile networksMedium; carrier-written labels are often accurate
dsl, adsl, ftth, cable, fiberFixed-line broadband access typeMedium
The IP itself encoded in the hostname, such as 203-0-113-25.xxxA generic PTR auto-generated by the carrier, common on customer address rangesMedium
static, biz, dedStatic address or business leased lineMedium to low
Cloud provider domain, compute, vps, server, hostDatacenter or cloud hostMedium
Airport code or city abbreviation, such as lax, fra, sjcCity where the equipment sitsLow; it only reflects where it was when named
Custom domain, such as mail.example.comSomeone configured it deliberately, probably a serverOnly shows that someone set it up

A few practical ways to read it:

  1. Look at the suffix domain. The registered domain on the far right (for example, a carrier's or cloud provider's domain) is usually the manager of the reverse zone. This is more reliable than the hostname prefix, because it is tied to the delegation chain.
  2. Check whether it was generated in bulk. A hostname that contains the IP itself in a tidy format means the carrier filled in the whole range automatically, which most likely means a customer access range.
  3. No PTR is information too. Many cloud hosts have no PTR by default, and many IPv6 addresses have none, so you cannot conclude anything from "not found" alone.

To cross-check these clues against more reliable data, read What is an ASN and how to look one up and How to find which ISP an IP belongs to. ASN and RDAP registration data come from address allocation records and are harder to change casually than a PTR.

How unreliable is a PTR?

Can a PTR contain anything? Yes. Whoever manages the reverse zone can fill in any string, including a domain they do not own. Setting an IP's PTR to mail.google.com, for example, is technically possible, and DNS does not verify it. So:

  • A PTR cannot prove identity. A hostname that looks like it belongs to a big company does not mean the IP belongs to that company.
  • A PTR can be stale. After an address block changes hands or a business changes, the old PTR often goes un-updated.
  • A PTR may not match actual use. A carrier may label a whole block dynamic, while some addresses in it were long ago assigned to business customers as fixed IPs.

That is why a PTR is only one of several signals when judging an IP's type. Datacenter IP vs residential IP: five signals websites use to spot residential IPs covers other signals that are harder to fake than a PTR.

FCrDNS: how to confirm a PTR was not made up

FCrDNS (Forward-Confirmed reverse DNS) closes the "anyone can write anything" gap in PTR:

  1. Look up the IP's PTR to get hostname H.
  2. Look up H's A (or AAAA) records to get a set of IPs.
  3. If the original IP is in that set, the check passes.

The logic is that the PTR is controlled by whoever manages the IP, while the A record is controlled by whoever owns the domain. If the two agree, the same party controls both the IP and the domain, so at least nobody is impersonating the other side unilaterally.

Here is the check on the command line:

ip=8.8.8.8
h=$(dig -x $ip +short | head -1)
echo "PTR: $h"
dig A $h +short | grep -qx "$ip" && echo "FCrDNS passed" || echo "FCrDNS failed"

Some server-side programs use this method to verify visitors, for example to confirm that a request claiming to be a search engine crawler really comes from that search engine (follow each vendor's official documentation for the exact method). FCrDNS only proves that "the IP and the domain are controlled by the same party". It does not prove that party is trustworthy.

Why a mail server must have a PTR

When you send mail from a self-hosted mail server, many receiving mail systems check the sending IP for:

  • whether a PTR exists;
  • whether the PTR passes FCrDNS;
  • whether the PTR looks like a generic dynamic address (for example, one containing dynamic, pool or an encoded IP);
  • in some cases, whether the PTR matches the hostname announced in the SMTP HELO/EHLO greeting.

Mail that fails these checks may be rejected, sent to spam, or rate limited. The exact policy is up to each recipient. When configuring, aim for the following:

CheckRecommendation
PTR recordSet it to the sending hostname, such as mail.example.com
Forward recordThe A/AAAA of mail.example.com points back to the same IP
HELO/EHLOThe mail server announces the same hostname
IPv6If the server sends over IPv6, configure a PTR for the v6 address too, or make it send over IPv4 only
SPF, DKIM, DMARCPTR is only the baseline; set up all three as well

Who can change a PTR record?

The most common mistake is to look for PTR settings in the domain registrar or in the DNS provider for your own domain. A PTR belongs to the reverse zone, and the reverse zone is delegated to whoever provides the IP, not to wherever your domain is hosted:

  • Cloud servers: look for "reverse DNS / rDNS / PTR" in the cloud provider's console, under the instance or elastic IP settings. Some providers require a support ticket, and some require the matching forward record to be set up first.
  • Colocation and dedicated servers: contact the datacenter or bandwidth provider.
  • Business leased lines and fixed-IP broadband: contact your carrier's account manager. Whether it can be changed depends on the service.
  • Address space you hold yourself (obtained from a regional registry): delegate the reverse zone to your own DNS at the registry, then maintain it yourself.
  • Ordinary home broadband: usually not changeable, and such addresses are not suitable for sending mail directly anyway.

To find out who owns an IP, use RDAP to look up registration data. See RDAP vs WHOIS: what's the difference.

A checklist you can follow

When you get an unfamiliar IP and want to quickly judge where it comes from, go in this order:

  1. Run dig -x <IP> to get the PTR, and note the hostname and the registered domain on the far right. If nothing comes back, look at the SOA in the AUTHORITY SECTION.
  2. Run an FCrDNS check on the hostname.
  3. Look up the ASN and RDAP registration data to see whether the block holder is a carrier, a cloud provider or a company.
  4. Compare the PTR clues with step 3. If they agree, confidence goes up a little. If they disagree, trust the registration data.
  5. If you are checking your own egress IP, open cdnping's IP and environment check. It shows RDAP network data, location voting across 11 geolocation databases, a datacenter / residential / mobile / Tor type verdict, and whether the IP is native or broadcast (for the concept, see native IP vs broadcast IP), all of which you can cross-check against the PTR clues.
  6. If the IP you find is not the egress you expected, for example the reverse lookup shows a residential ISP but you thought you were going through a proxy, see how to check for CGNAT and how Chinese websites see your real IP.

Related articles

Keep reading