Scrapeless Wiki

What Is Reverse DNS? – Definition and How It Works

Informational P3 what is reverse dns

Learn how reverse DNS maps an IP to a hostname, why forward-confirmed lookups matter, and how crawler verification uses it.

Reverse DNS resolves an IP address to a hostname, the opposite of an ordinary lookup. It uses PTR records in a special zone derived from the address itself.

1. How It Works

The address is reversed and placed under in-addr.arpa:

203.0.113.42  β†’  42.113.0.203.in-addr.arpa  β†’  PTR  host.example.com
dig -x 203.0.113.42 +short

The reversal exists so that delegation follows address allocation: the owner of a block controls the corresponding reverse zone.

2. Who Controls It

The address holder, not the domain owner. Whoever is delegated the address block sets its PTR records.

That has a direct consequence: anyone can set a PTR record claiming any hostname for an address they control. A PTR alone proves nothing, and taking one at face value is the standard mistake.

3. Forward-Confirmed Reverse DNS

The verification that makes it trustworthy is a two-step check:

  1. Reverse-resolve the IP to a hostname.
  2. Forward-resolve that hostname back to addresses.
  3. Confirm the original IP is among them.

Both directions must agree. The reverse record is controlled by the address holder; the forward record is controlled by the domain owner. Only someone controlling both can produce a consistent pair.

import socket

def fcrdns(ip):
    try:
        host, _, _ = socket.gethostbyaddr(ip)
    except OSError:
        return None
    try:
        _, _, addrs = socket.gethostbyname_ex(host)
    except OSError:
        return None
    return host if ip in addrs else None

4. Verifying a Search Engine Crawler

This is the canonical use. Major search engines publish that their crawlers should be verified this way rather than by user-agent string or by an IP allowlist, because a user agent is trivially forged and their address ranges change.

The check: reverse-resolve the requesting address, confirm the hostname is in the engine's documented domain, and forward-resolve it back to the same address.

For anyone operating a crawler, the implication is the reverse: a user-agent string claiming to be a search engine while failing this check identifies itself as an impostor. Do not claim to be someone else's crawler β€” it is checkable, and failing the check is worse than an honest identifier.

5. Other Uses

Mail server reputation. Receiving mail servers commonly require a valid PTR matching the sending host, and its absence is itself a spam signal.

Log readability, where hostnames are more informative than addresses β€” at the cost of a lookup per entry.

Network classification, since hosting providers' PTR records frequently encode the datacenter and region. Useful and only indicative, since the ASN is the authoritative source.

6. Why It Often Fails

  • No PTR record exists. Very common, particularly on consumer connections.
  • The generic default β€” many providers set an automatic PTR naming the provider, which conveys nothing about the host.
  • Forward and reverse disagree, which is exactly what the check is for.
  • IPv6 PTRs are rare, so the technique is far less useful there.
  • Slow or unavailable reverse zones, so lookups time out.

A missing PTR is normal and not evidence of anything, which is why absence must not be treated as a signal.

7. Operational Notes

  • Cache results. A reverse lookup per log line is an unnecessary load on resolvers and on your own throughput.
  • Set a short timeout. Reverse zones are frequently slow or absent, and a blocking lookup should not hold a request path.
  • Never trust a PTR alone. Always forward-confirm.
  • Do not use it for authorisation on its own; it is a weak signal, appropriate as one input.
  • Expect no answer for most consumer addresses.

8. Summary

Reverse DNS maps an address to a hostname via PTR records in in-addr.arpa, controlled by the address holder rather than the domain owner β€” so a PTR by itself proves nothing.

Forward-confirmed reverse DNS, where the hostname resolves back to the original address, is the check that has meaning, and it is the documented method for verifying a search-engine crawler β€” which is also why a crawler should never claim someone else's identity.