Netblock Notes

Home › Basics › Reverse DNS Lookup by IP: Commands, PTR Records, Pitfalls

Reverse DNS Lookup by IP: Commands, PTR Records, Pitfalls

Editorial team · Updated 2026-10-14 · 5 min read

A reverse DNS lookup by IP asks the DNS for the PTR record attached to an address and returns a hostname if one exists. On a command line, dig -x 203.0.113.7 does it in one step. The answer is only as trustworthy as the party who published it, so treat the hostname as a hint, not proof.

How the reverse lookup is built

Normal DNS goes from a name to an address. Reverse DNS goes the other way by turning the address into a special name. For IPv4 the four octets are reversed and .in-addr.arpa is appended, as set out in RFC 1035. The example address 203.0.113.7, taken from the range reserved for documentation in RFC 5737, becomes 7.113.0.203.in-addr.arpa. The resolver asks for a PTR record at that name.

IPv6 works the same way in spirit but is longer. RFC 3596 defines the ip6.arpa domain, where every hexadecimal digit of the full 128-bit address becomes its own label, reversed. Nobody writes these by hand; the tools do it for you.

The key point is delegation. The reverse zone for a block is controlled by whoever holds the block, and they normally delegate it further to customers who ask. That is why you set a PTR record in your hosting panel or by asking your provider, not in your own domain’s zone file.

Commands that work

Tool Command Notes
dig dig -x 203.0.113.7 +short Prints only the hostname; best for scripts
host host 203.0.113.7 Short, readable output on Linux and macOS
nslookup nslookup 203.0.113.7 Available on Windows, Linux and macOS
Python socket.gethostbyaddr("203.0.113.7") Raises an error if no record exists; see our Python example

If the command returns NXDOMAIN or no answer, no PTR record exists for that address. That is a normal result, not an error in your command.

Reading the result

A PTR record is a string chosen by the holder. Sometimes it is informative: mail-out-04.example-corp.com tells you a company runs a mail server there. Often it is generic and generated from the address, such as static-203-0-113-7.provider.example, which tells you only that a provider assigned it. Neither version says who is using the connection.

Key takeaway: a hostname can be wrong or misleading because the holder can write anything in it. To make it more reliable, confirm the name resolves forward to the same address, a check often called forward-confirmed reverse DNS.

The forward-confirmation step is simple. Take the hostname returned, resolve it to an address, and see whether the original IP is among the results. If it is, the owner of both the reverse and forward zones agreed on the name. If it is not, discard the hostname as unverified.

Where reverse DNS falls short

Reverse DNS is the right tool when the question is “what does this server call itself?” It is a weak tool for other questions.

  • Who owns the network? PTR records do not carry ownership. Use a WHOIS or RDAP query for the registered holder.
  • Which websites share this server? A PTR record shows one name, not the many sites that may share the address. See reverse IP domain lookup.
  • Which company is behind this visit? Business networks often have no helpful PTR record. A company-level lookup, such as BusinessMCP’s free reverse IP lookup tool, draws on other data. Its page describes company name and domain for business networks and an ISP or hosting label otherwise.

Practical checklist for logs and mail

  1. Collect the address from the log entry, not from a header that a client can forge.
  2. Run dig -x and record whether a PTR exists.
  3. Resolve the returned name forward and compare.
  4. If the hostname looks generated, move on to registry data.
  5. If you are running a mail server, ask your provider to set a PTR that matches the server’s hostname, because many receiving systems check it.

For mail deliverability, many large receivers expect a matching PTR, but the exact rules differ by receiver. Check the postmaster pages of the services you send to rather than assuming.

Reverse DNS versus the wider reverse IP lookup

Reverse DNS is one slice of the topic. Our explanation of what a reverse IP lookup is lays out the four common meanings. If your real goal is turning an address into a business name, a tool built for that purpose, like the one described in BusinessMCP’s guide to visitor identification, will save time. That guide is a vendor source and states match-rate figures you should test on your own traffic.

Troubleshooting

If results differ between machines, a local resolver cache may be serving older answers. Ask a public resolver directly with dig @1.1.1.1 -x ... or another resolver you trust, and compare. If a PTR changed recently, wait for the record’s time-to-live to expire. For internal ranges, such as the private blocks in RFC 1918, the public DNS will not hold any record, and your own network’s DNS has to.

Examples of what you will see

Reverse DNS results tend to fall into a few recognisable patterns, and learning them speeds up log reading.

Descriptive hostnames. A name like smtp-gw1.example-corp.com suggests a company mail gateway. These are the most useful answers, because the organisation chose to describe the machine. They are common for mail servers and managed infrastructure.

Generated hostnames. Names built from the address, such as digits separated by hyphens followed by a provider domain, are created automatically for whole blocks. They confirm the provider but say nothing about the customer. This is the usual result for home broadband.

Cloud default names. Large cloud platforms assign each server a default hostname that usually contains the address and the platform’s domain. Seeing one tells you the traffic came from rented infrastructure, which may be a legitimate service, a proxy or an automated client.

No record at all. This is common, particularly for residential and mobile space. It does not indicate a problem with the address or your query.

Scripting it safely

If you automate reverse lookups across a log file, a few habits prevent trouble. Deduplicate addresses first, because logs repeat the same visitors many times. Set a timeout, since DNS queries to unresponsive servers can hang. Cache results for the record’s time-to-live instead of re-querying. And never trust a hostname to make a security decision on its own, since it is controlled by the address holder and can be set to anything. Use it as one signal alongside the registry holder and observed behaviour.

For larger sets, a dedicated service may be more practical than raw DNS, because it can combine PTR data with ownership and classification. BusinessMCP, for example, documents a bulk endpoint on its IP to company API page that accepts 1 to 100 addresses per call, which you can compare against a home-grown DNS script. See also bulk reverse IP lookup.

Frequently asked questions

How do I do a reverse DNS lookup by IP address?

Run dig -x 203.0.113.7, host 203.0.113.7 or nslookup 203.0.113.7. Each asks DNS for the PTR record that belongs to the address.

Why does my IP have no reverse DNS record?

The holder of the address block has to publish PTR records. Many networks, especially residential ones, publish none or only a generic name.

What is forward-confirmed reverse DNS?

It is a check where you resolve the PTR hostname back to an address and confirm it matches the original. Mail servers often rely on it.

Can I set a PTR record myself?

Only through whoever controls the address range, usually your hosting or internet provider. Your own domain’s DNS zone does not control it.

Sources