Reverse DNS: what PTR records are actually for
By Parneet7 min read
Forward DNS turns a name into an address. Reverse DNS does the opposite — and almost everything about how it works is stranger than the forward case, for reasons that are historical rather than sensible.
Most of the time you can ignore it. Then you set up a mail server and it becomes the difference between delivered and silently rejected.
How the reverse lookup actually works
There is no "reverse lookup" mechanism in DNS. There is only forward lookup, so reverse queries are faked by constructing a name out of the address.
For IPv4, reverse the octets and append in-addr.arpa:
115.186.215.17 → 17.215.186.115.in-addr.arpa
Then query that name for a PTR record. The reversal exists because DNS names get more specific right to left, while IP addresses get more specific left to right — so the address has to be flipped to fit the tree.
IPv6 is the same idea, taken further: each hex digit becomes its own label, in
reverse, under ip6.arpa. A single address becomes 32 labels. It is as
unpleasant to read as it sounds, and you will never write one by hand.
Who controls it — and why you probably cannot
This is the part that surprises people. You do not control the PTR record for your own address.
Forward DNS is delegated to whoever owns the domain. Reverse DNS is delegated with the address block, which means it belongs to whoever was allocated that block — your hosting provider, your ISP, or a Regional Internet Registry.
If you want a PTR record for your server, you ask your provider to set it. Most have a control panel field for it; some require a support ticket. If you rent a single address from a consumer ISP, you may not be able to set it at all.
Adding a PTR to your own zone file does nothing. It has to live in the reverse zone, and you almost certainly do not control that zone.
Where it actually matters
This is the big one, and it is unforgiving.
Receiving mail servers routinely check that a connecting server has a PTR record, and that the PTR is consistent. Specifically they want forward-confirmed reverse DNS: the address has a PTR pointing to a hostname, and that hostname resolves forward back to the same address.
115.186.215.17 → PTR → mail.example.com
mail.example.com → A → 115.186.215.17 ✓ consistent
Two things fail this check regularly:
- No PTR at all. Treated as a strong spam signal, sometimes an outright rejection.
- A generic ISP-assigned PTR like
115-186-215-17.ip4.example-isp.net. These are the default on consumer and business broadband, and they mark the address as one that should not be originating mail.
The PTR should also match the hostname your mail server announces in its
HELO/EHLO greeting. A server greeting as mail.example.com from an address
whose PTR says something else looks misconfigured, because it is.
Logs and diagnostics
Reverse lookups turn addresses into readable names in traceroutes and access logs. Router naming conventions often encode the city and link type, which is genuinely useful when tracing a path.
Be careful trusting it for anything else — PTR records are set by the address
holder and are not verified against anything. A PTR claiming google.com proves
nothing without a forward confirmation.
Legacy access control
Some older systems still do reverse lookups for access control. This is weak on its own for the reason above, and doubly weak because a failed lookup blocks legitimate users while a determined attacker sets whatever PTR they like on address space they control.
Diagnosing it
dig -x 115.186.215.17 +short
Then confirm the forward direction matches:
dig mail.example.com +short
If the two do not agree, you have found the problem. It is worth checking whenever mail deliverability degrades for no visible reason — a provider renumbering an address, or resetting a PTR to its default, produces exactly that symptom.
What to do
Running a mail server: get the PTR set to the hostname the server announces, and make sure it forward-resolves back. This is not optional; it is the baseline receivers expect. It also does not replace SPF, DKIM or DMARC — it sits alongside them.
Running anything else: you probably do not need a PTR, though having a sensible one makes your traffic easier for others to identify.
Consuming reverse DNS: never trust a PTR without forward confirmation, and do not build access control on it.
The reverse DNS generator builds the
in-addr.arpa and ip6.arpa names for any address, which saves reversing 32
hex labels by hand. Every lookup through the API returns the ASN and
organisation for an address, which is often what you were actually trying to
learn from the PTR.