A reverse DNS lookup asks the DNS for the hostname that belongs to an IP address, using a PTR record. Run dig -x 203.0.113.25 +short on macOS or Linux, or nslookup 203.0.113.25 on Windows, and replace the address with the one you want to check.
The addresses in this article come from the reserved documentation ranges, so they will not return real answers. All output shown is example output.
How to run a reverse DNS lookup
With dig (macOS and Linux)
dig -x 203.0.113.25 +short
Example output:
mail.example.com.
The -x option exists for this job: it takes an IPv4 address in dotted-decimal form or an IPv6 address with colons, builds the reversed name for you, and asks for its PTR record. Without +short, dig prints the full response, and the answer section shows the name it actually queried:
;; ANSWER SECTION:
25.113.0.203.in-addr.arpa. 3600 IN PTR mail.example.com.
If the address has no PTR record, the answer section is empty and the status is usually NXDOMAIN (the name does not exist) or NOERROR with zero answers.
With nslookup (Windows, macOS and Linux)
nslookup 203.0.113.25
Microsoft's documentation states that when the thing you look up is an IP address and the query type is A or PTR, nslookup returns the name of the computer. Example output:
Server: dns.example.net
Address: 192.0.2.53
Name: mail.example.com
Address: 203.0.113.25
To ask a specific DNS server instead of your default one, add it as the second argument: nslookup 203.0.113.25 1.1.1.1. If the lookup fails, nslookup prints one of its documented errors. Nonexistent domain means the name does not exist, which for a reverse lookup means no PTR record. timed out and No response from server point at the DNS server you asked, not at the address.
With an online tool
Web-based reverse lookup pages run the same PTR query from their own servers. That is useful when you want to see what the outside world sees rather than what your local resolver returns. The answer is the same data, so a missing PTR record is missing everywhere.
What a PTR record is
A normal DNS lookup (a forward lookup) maps a name to an address through an A or AAAA record. A PTR record goes the other way. RFC 1035 defines it as a record whose data is a single domain name, and notes it is used in special domains such as IN-ADDR.ARPA to point to another location in the name space. For a list of the other record types, see DNS record types explained.
The two directions are independent. Creating an A record for mail.example.com does nothing for reverse DNS. The PTR record has to be created separately, in a different zone, by a different party.
How the reverse name is built (IPv4)
IPv4 reverse lookups query a name under in-addr.arpa, with the four octets written in reverse order. RFC 1035 gives the example of the address 10.2.0.52, stored under 52.0.2.10.IN-ADDR.ARPA. The same rule applied to our example address:
| Address | Name queried for the PTR record |
|---|---|
203.0.113.25 | 25.113.0.203.in-addr.arpa |
10.2.0.52 | 52.0.2.10.in-addr.arpa |
The order looks backwards because names in DNS are read from the most specific part on the left to the root on the right, while an IP address goes from the network part on the left to the host part on the right. RFC 1035 admits the reversal is awkward to read, and explains why it was chosen: it allows zones to be delegated that cover exactly one network of address space. You can run the lookup by hand to see this:
dig PTR 25.113.0.203.in-addr.arpa +short
That returns the same result as dig -x 203.0.113.25 +short.
How IPv6 reverse lookups work
IPv6 reverse names live under ip6.arpa and are written one hexadecimal digit (a nibble) at a time, again in reverse order. RFC 3596 shows the address 4321:0:1:2:3:4:567:89ab as:
b.a.9.8.7.6.5.0.4.0.0.0.3.0.0.0.2.0.0.0.1.0.0.0.0.0.0.0.1.2.3.4.IP6.ARPA.
All 32 digits are written out, including zeros that the short form of the address hides. You do not need to build this by hand: dig's -x option does it, and by default it looks IPv6 addresses up in nibble format under ip6.arpa.
dig -x 2001:db8::1 +short
Who controls the PTR record for an IP address
Whoever the address block is delegated to controls the reverse zone. For most people that is an internet provider or a cloud host, not the owner of the domain name. This has practical consequences:
- You cannot add the record at your domain registrar or DNS host. Your domain's zone holds A, MX and TXT records. The PTR record belongs in the reverse zone of the IP block.
- Cloud and hosting providers usually expose a setting. Look for a "reverse DNS" or "PTR" field next to the server's IP address in the provider's control panel, or open a support request.
- Home connections typically have a generic name or none. A residential provider often publishes an automatic name derived from the address, and may not let you change it.
- Small blocks need special delegation. Reverse zones are normally split on octet boundaries, which a block smaller than a /24 does not fit. RFC 2317 describes the workaround: the parent zone adds a CNAME for each address that points into a child zone named after the block, such as
1 CNAME 1.0/25for 192.0.2.0/25. If your provider hands you a few addresses, this is how they delegate reverse DNS to you. For how block sizes are written, see CIDR notation explained.
Why a reverse lookup fails or looks wrong
- No PTR record exists. The most common cause. The lookup returns
NXDOMAINin dig orNonexistent domainin nslookup. - The name is generic. A hostname made of the IP address inside a provider's domain means the provider created a default record. Nobody has set a meaningful name.
- The PTR name and the A record disagree. The two are published by different parties and nothing forces them to match. Because a PTR record can hold any name, treat it as a hint. To check it, run a forward lookup on the returned name and confirm the address comes back.
- Stale cache. Resolvers keep answers for the record's TTL (the number after the name in dig output, in seconds). After a change, an old answer can persist until it expires. See how to flush the DNS cache for your local machine.
- The DNS server you asked is failing. Errors such as
timed outorServer failureconcern the server, so retry against another resolver, for exampledig -x 203.0.113.25 @1.1.1.1.
For the general picture of how a query travels from your device to an answer, read how DNS works.
Frequently asked questions
- Why does a reverse DNS lookup return nothing for my IP address?
- Reverse DNS only works if someone created a PTR record for that address. The record lives in a zone controlled by whoever the address block is delegated to, usually your ISP or hosting provider, so no PTR record means the lookup returns no answer. Ask that provider to set it, or use their control panel if it has a reverse DNS field.
- Can one IP address have more than one PTR record?
- Yes. DNS allows several PTR records under the same name, and a lookup returns all of them. Many setups publish just one, because software that reads the result often uses only the first name it receives.
- Does a PTR record prove who owns an IP address?
- No. Whoever controls the reverse zone can put any hostname in a PTR record, including one for a domain they do not own. To check that a name is genuine, look up the name it returns and confirm that its A or AAAA record points back to the same IP address.
- Is reverse DNS the same as a WHOIS lookup?
- No. Reverse DNS reads a PTR record from the DNS. WHOIS and RDAP report who a network block is registered to. The two are maintained separately and can disagree.