Skip to content

/commands/dig/dig-reverse-dns-lookup

dig -x IP: reverse DNS lookup (PTR record)

The commands on this page have not been executed by our verification runner yet.updated
tool
dig / nslookup
versions
BIND 9 dig
os
linux, macos, windows

dig -x 192.0.2.10 performs a reverse DNS lookup: it asks for the PTR record of the address and prints the host name the address owner configured. Add +short to print only the name. dig builds the special query name for you (10.2.0.192.in-addr.arpa. for IPv4, a nibble-reversed ip6.arpa. name for IPv6) and sets the query type to PTR.

Usage

bash
dig -x 8.8.8.8 +short
dig -x 2001:4860:4860::8888 +short
dig -x 8.8.8.8 @1.1.1.1 +short        # ask a specific resolver
dig -x 8.8.8.8 +noall +answer         # answer section only, with TTL

dig -x 8.8.8.8 +short returns dns.google. at the time of writing; the trailing dot marks a fully qualified name.

The equivalent explicit query

bash
dig PTR 8.8.8.8.in-addr.arpa +short

-x only saves you from reversing the octets (or, for IPv6, the 32 hexadecimal nibbles) and appending the in-addr.arpa or ip6.arpa zone.

Reading the result

ResultMeaning
A host namethe PTR record exists
Empty output with +short, status NOERRORthe name exists but has no PTR record
status: NXDOMAINno reverse entry for this address
status: SERVFAILthe reverse zone is broken or not reachable
Several namesseveral PTR records; allowed, but many tools use only the first

Reverse records are managed by whoever controls the address block (your hosting or cloud provider, or your ISP), not in your domain's zone. Mail servers commonly check that the PTR name resolves back to the same address (forward-confirmed reverse DNS); check it with dig +short $(dig -x IP +short).

Sources