Sub topic 11
Reverse DNS and PTR records
This chapter assumes you know how forward lookups work, what a resource record is, and how zones are delegated. It also assumes you can read basic dig output.
What reverse DNS does
Forward DNS maps a name to an address. Reverse DNS maps an address back to a name. The record type that holds the answer is the PTR (pointer) record.
Reverse lookups are mostly used for logging, diagnostics and mail. Tools such as traceroute show names instead of bare addresses. Mail servers often check that a sending IP has a PTR record, and treat a missing one as a sign of spam.
How the reverse tree is built
The DNS tree is organized by name, not by number. To look up an address, DNS turns it into a name under a special domain.
- For IPv4, the four octets are written in reverse order and followed by
in-addr.arpa. - For IPv6, each of the 32 hexadecimal digits becomes its own label, in reverse order, followed by
ip6.arpa.
The octets are reversed so that the most specific part is on the left. Names get more general toward the right, and delegation follows the same direction. This means the owner of a network block can be delegated the matching part of the reverse tree.
| Address | Reverse name |
|---|---|
| 192.0.2.10 | 10.2.0.192.in-addr.arpa. |
| 192.0.2.0/24 (zone) | 2.0.192.in-addr.arpa. |
| 2001:db8::10 | 0.1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa. |
Who controls the reverse zone
The reverse tree is delegated by address allocation, not by domain registration. The regional internet registries hand blocks to providers. A provider then delegates reverse zones to customers, or edits the PTR records on request. If you rent a server, you usually set its PTR record in your hosting provider's control panel and not in your own zone file.
Querying a PTR record
The -x option builds the reverse name for you and asks for the PTR record.
dig -x 192.0.2.10 +noall +answerA typical answer looks like this:
10.2.0.192.in-addr.arpa. 3600 IN PTR mail.example.com.Inside the zone 2.0.192.in-addr.arpa., the record is written with only the host octet as its owner name:
$ORIGIN 2.0.192.in-addr.arpa.
$TTL 3600
10 IN PTR mail.example.com.The target must be a fully qualified name that ends with a dot. If you leave the dot off, the zone's origin is appended, and the record points to the wrong name.
Forward-confirmed reverse DNS
A PTR record is only a claim made by whoever controls the reverse zone. That owner can write any name there, even one belonging to someone else. A PTR record alone therefore proves nothing.
Forward-confirmed reverse DNS (FCrDNS) closes the gap in three steps:
- Look up the PTR record for the client's IP address.
- Look up the A or AAAA records of the name that came back.
- Accept the result only if the original IP appears in those records.
A mail server with the address 192.0.2.25 should therefore have a PTR record for mail.example.com. and an A record for mail.example.com. that points back to 192.0.2.25.
Common errors
- No PTR record. Many mail servers reject or penalize mail from such addresses.
- PTR and A do not match. The reverse name resolves to a different address, so the FCrDNS check fails.
- Editing the wrong zone. Adding a PTR record to
example.comdoes nothing. It belongs in the reverse zone, which your address provider controls. - Several PTR records on one address. This is allowed but confuses some software. Keep one unless you have a reason.
Exercise
What is the reverse lookup name for 198.51.100.7, and why can you not fix a missing PTR record by editing your own forward zone for example.com?
Show answer
The name is 7.100.51.198.in-addr.arpa. PTR records live in the reverse tree, which is delegated along address allocations. The block's owner, usually your ISP or hosting provider, controls that zone, so the record must be added there and not in example.com.