There are two types of mappings: forward mapping and reverse mapping. In forward mapping, name servers translate names into IP addresses. In reverse mapping, they translate IP addresses into names.
In the DNS system, only authoritative name servers resolve queries. There are two types of authoritative name servers: primary and secondary. The primary name server resolves queries. The secondary name server works as a backup name server. It resolves queries when the primary name server is down.
To resolve queries, authoritative name servers use zone files. Zone files are created only on primary name servers. Secondary name servers fetch them from the primary name server.
Lab setup
We will use the following lab setup.
To learn how to set up this lab, you can check the previous tutorials of this tutorial series.
This tutorial is the last tutorial of the tutorial series "How to configure DNS name servers in Linux.". Previous tutorial of this tutorial series are the following.
How to configure DNS Server in Linux
How to configure a caching only name server
How to configure DNS Forwarding and a forwarder name server
How to configure a primary or master authoritative name server
How to configure a secondary or slave authoritative name server
Configuring reverse mapping on the primary authoritative name server
On RHELServer1, open /etc/named.conf and add the following zone configuration.
zone "29.168.192.in-addr.arpa"{ type master; file "29.168.192.db"; allow-transfer {192.168.29.101;}; };
The type option configures this name server as the primary authoritative name server for this zone.
The file option defines the zone file for this zone. On the primary name server, we need to manually create this file. The secondary name server automatically fetches it from the primary name server.
The allow-transfer option defines the secondary or slave name server's IP address. The primary name server transfers the zone file to the name server defined in this option.
Creating a reverse zone file
Create a reserve zone file named 29.168.192.db in the /var/named/ directory and add the following configuration to it.
To learn about the zone file's options, you can check the following tutorial series. It explains zone files and their options in detail.
DNS zone file Format, Configuration, and Directives
Adding a firewall rule for the DNS service
By default, the firewall does not allow incoming DNS traffic. Use the following command to add an allow rule for DNS traffic in the firewall.
#firewall-cmd --zone=public --add-service=dns --permanent
In the testing environment, you can skip the --permanent flag. If you skip this flag, this rule will persist only in the current session.
Restart the named service.
Configuring reverse mapping on a secondary authoritative name server
On RHELServer2, open /etc/named.conf and add the following zone configuration.
zone "29.168.192.in-addr.arpa"{ type slave; file "slaves/29.168.192.db"; masters {192.168.29.100;}; };
The type option configures this name server as the secondary authoritative name server for this zone.
The file option defines the zone file for this zone. Since it is a slave name server, we do not need to create this file. It will automatically fetch the file from the primary name server and save it in the /var/named/slaves directory.
The masters option defines the primary or master name server's IP address. The slave name server automatically fetches the zone file from the master name server defined in this option.
Add an allow rule in the firewall for DNS traffic.
Restart the named service and verify the zone transfer.
Testing and verifying reverse mapping
To test and verify reverse mapping, we can use the host command with the -a option. It sends a DNS query to the configured name server to translate the supplied name or IP address and prints the answer.
The following command sends a query to the configured DNS server to translate the IP address 192.168.29.200.
#host -a 192.168.29.200

As we can see in the above output, the query has been resolved by the primary name server.
Now stop the named service on RHELServer1.
Use the same command on RHELClient.
As we can see in the above output, the query has been resolved by the secondary name server. It verifies when the primary name server is up, it resolves queries. When the primary name server is down, the secondary name resolves queries.