Reverse DNS: look up the PTR record of an IP address

· 3 min read

Reverse DNS answers the question the other way round: which name belongs to this IP address? For mail servers the answer is decisive, because many receivers reject mail from addresses without a matching PTR record. This guide shows the lookup with dig, nslookup, PowerShell and host, the forward confirmation, and how to find the public IP address of your server.

PTR record lookup

Enter the IPv4 or IPv6 address you want to check. The default comes from a range reserved for examples and has no PTR record itself.

Tool

Only inserted into the commands in your browser.

dig · Linux, macOS

-x reverses the address for you and asks for the PTR record. You get the host name the IP's owner has published. An empty answer means there is no PTR record.

Shell
dig +short -x 192.0.2.25
Sample output
mail.example.com.

nslookup · Windows, Linux, macOS

Given an IP address, nslookup asks for the PTR record by itself. On the left is the reversed address under in-addr.arpa, on the right the host name.

Shell
nslookup 192.0.2.25
Sample output
Non-authoritative answer:
25.2.0.192.in-addr.arpa	name = mail.example.com.

PowerShell · Windows

The NameHost column holds the host name. Without a PTR record Resolve-DnsName raises an error instead of returning nothing.

PowerShell
Resolve-DnsName -Name 192.0.2.25 -Type PTR

host · Linux, macOS

One sentence in reply; without a PTR record it reads "not found: 3(NXDOMAIN)".

Shell
host 192.0.2.25
Sample output
25.2.0.192.in-addr.arpa domain name pointer mail.example.com.

Behind the scenes the address is reversed and queried in a zone of its own: 192.0.2.25 becomes 25.2.0.192.in-addr.arpa. For IPv6 every hex digit stands alone, backwards, under ip6.arpa. That is the typing -x saves you.

Forward confirmation: does the name point back?

A PTR record alone does not satisfy mail servers. They check that the name they found resolves to the same address again (forward-confirmed reverse DNS). For a domain's mail server that is three lookups: the MX, its address, and that address's PTR.

Shell
dig +short MX example.com
dig +short A mail.example.com
dig +short -x 192.0.2.25

# confirmation in one step: the output must be the IP again
dig +short A $(dig +short -x 192.0.2.25)

If both directions agree and the mail server introduces itself with the same name when it connects, the requirement is met. Gmail and Microsoft expect this from every sender.

Find the public IP address of your server

Behind a router or in a cloud you often know only the internal address. A DNS trick reveals the public one: the OpenDNS resolver answers the name myip.opendns.com with the address the query came from.

Shell
# IPv4
dig +short -4 myip.opendns.com @resolver1.opendns.com
nslookup myip.opendns.com 208.67.222.222

# IPv6
dig +short -6 AAAA myip.opendns.com @resolver1.opendns.com

# PowerShell
Resolve-DnsName -Name myip.opendns.com -Server 208.67.222.222 -Type A

Mind the -4. On a connection with IPv6, dig reaches the resolver over IPv6 but asks for an A record, and the answer comes back empty; nslookup then says "No answer". With -4, or the resolver's IPv4 address (208.67.222.222), it works. For the IPv6 address ask for type AAAA.

What the answer means

Typical results and what to do:

  • NXDOMAIN or an empty answer: there is no PTR record. Mail from this address is often rejected or lands in spam.
  • The name looks like "ip-192-0-2-25.example.net": a provider default. Not good enough for a mail server; set the server's host name.
  • You cannot find the PTR in your domain's DNS editor: it does not belong there. The PTR record is set by whoever owns the IP address, your hosting provider, usually in the customer portal under "reverse DNS" or "rDNS".
  • The forward lookup returns a different IP: the name's A record points elsewhere, often after a server move.
  • IPv4 has a PTR, IPv6 does not: if the server sends over IPv6, the missing record there is what counts. Add it or restrict sending to IPv4.
  • Several names in the answer: permitted, but receivers treat it inconsistently. One PTR per address is the safe choice.

Checking without a terminal

The blacklist check finds the addresses of a domain's mail servers and website and queries them against the important DNS blocklists, which work on the same reversed-address principle. What to do when an address is listed is covered in the blacklist delisting guide.

Frequently asked questions

How do I run a reverse DNS lookup on Windows?
nslookup followed by the IP address, for example nslookup 192.0.2.25, or in PowerShell Resolve-DnsName -Name 192.0.2.25 -Type PTR. The answer gives the published host name.
Where is the PTR record configured?
With the owner of the IP address, meaning your hosting provider or ISP, not in your domain's DNS zone. Most hosts offer a "reverse DNS" field in their customer portal.
How do I show my public IP address from the command line?
dig +short -4 myip.opendns.com @resolver1.opendns.com or nslookup myip.opendns.com 208.67.222.222. The OpenDNS resolver answers with the address the query came from.
Do I need a PTR record for my website?
No. Browsers do not check reverse DNS. The PTR record matters for servers that send mail.
Check now

Free blacklist check for a domain (mail server and website IPs, IPv4 and IPv6) or a single IP: Spamhaus, Spamcop, Barracuda, PSBL, SURBL. With delisting.

DomainWarn checks your clients' mail server IPs against the relevant blocklists on a schedule and alerts you to a listing before the first bounces arrive.

Monitor this domain continuously14-day free trial, no credit card.

More guides