Sub topic 15
Reverse Zones and PTR Records
Prerequisites and purpose
This chapter assumes you can edit BIND configuration, restart services with systemctl, and use dig. A reverse DNS lookup starts with an IP address and returns a host name. DNS stores this information in a PTR resource record, which maps one address to one canonical name.
Reverse DNS is useful in mail-server checks, log files, monitoring, and access-control decisions. It does not replace forward DNS. A reliable setup usually has both:
- Forward lookup:
server.lab.example→192.0.2.20 - Reverse lookup:
192.0.2.20→server.lab.example
How reverse zones work
IPv4 reverse names use the in-addr.arpa domain. Reverse the address octets and append that suffix. For 192.0.2.20, the query name is 20.2.0.192.in-addr.arpa.
A zone for the entire 192.0.2.0/24 network is named 2.0.192.in-addr.arpa. The address's final octet becomes the record owner inside that zone.
Defining a reverse zone in BIND
Add this zone declaration to the authoritative server's configuration:
zone "2.0.192.in-addr.arpa" {
type primary;
file "/etc/bind/db.192.0.2";
allow-query { any; };
};Create /etc/bind/db.192.0.2:
$TTL 3600
@ IN SOA ns1.lab.example. hostmaster.lab.example. (
2026112801 ; serial
7200 ; refresh
3600 ; retry
1209600 ; expire
3600 ) ; negative caching TTL
IN NS ns1.lab.example.
20 IN PTR server.lab.example.
25 IN PTR mail.lab.example.The owner 20 represents 20.2.0.192.in-addr.arpa. The trailing dot in each full name prevents BIND from appending the zone name accidentally. Increase the SOA serial whenever you change the zone. A secondary server uses that serial to decide whether it needs an update.
Check and reload the configuration:
sudo named-checkconf
sudo named-checkzone 2.0.192.in-addr.arpa /etc/bind/db.192.0.2
sudo rndc reload 2.0.192.in-addr.arpa
dig @127.0.0.1 -x 192.0.2.20 +shortExpected output is:
server.lab.example.Delegation and common errors
For a network you do not own, the address provider must delegate the reverse zone to your name servers. Adding a local zone cannot control public reverse DNS.
Common errors include reversing the octets incorrectly, omitting the final dot, leaving the serial unchanged, and testing a different resolver than the one you configured. IPv6 uses the ip6.arpa domain and reverses every hexadecimal nibble, so it requires a different zone design.
Exercise
Which BIND zone contains the PTR record for 192.0.2.25, and what owner name represents that address?
Show answer
The zone is 2.0.192.in-addr.arpa, and the owner name is 25.