Reverse DNS (rDNS) is the naming method of the machine that is using a given IP and is defined by the IP block administrators through the PTR record in DNS.
How to discover the rDNS of an IPv4
To discover the rDNS of an IPv4, just consult the PTR of the IP reverse form with “.in-addr.arpa”. As an example, the IP “220.127.116.11” is transformed into “18.104.22.168.in-addr.arpa” and the PTR record is query:
ubuntu:~$ dig PTR 22.214.171.124.in-addr.arpa +noall +answer
; > DiG 9.9.5-3ubuntu0.8-Ubuntu > PTR 126.96.36.199.in-addr.arpa +noall +answer
;; global options: +cmd
188.8.131.52.in-addr.arpa. 32 IN PTR mail-oi0-f43.google.com.
As can be seen in the example, the IP rDNS “184.108.40.206” is “mail-oi0-f43.google.com”.
How to discover the rDNS of an IPv6
To discover the rDNS of an IPv4, just consult the PTR of the IP reverse form with “.ip6.arpa”. As an example, the IP “2607:f8b0:400c:c05::22f” is transformed into “f.220.127.116.11.0.0.0.0.0.0.0.0.0.0.0.5.0.c.0.c.0.0.4.0.b.8.f.18.104.22.168.ip6.arpa” and the PTR record is query:
ubuntu:~$ dig PTR f.22.214.171.124.0.0.0.0.0.0.0.0.0.0.0.5.0.c.0.c.0.0.4.0.b.8.f.126.96.36.199.ip6.arpa +noall +answer
; > DiG 9.9.5-3ubuntu0.8-Ubuntu > PTR f.188.8.131.52.0.0.0.0.0.0.0.0.0.0.0.5.0.c.0.c.0.0.4.0.b.8.f.184.108.40.206.ip6.arpa +noall +answer
;; global options: +cmd
f.220.127.116.11.0.0.0.0.0.0.0.0.0.0.0.5.0.c.0.c.0.0.4.0.b.8.f.18.104.22.168.ip6.arpa. 60 IN PTR mail-vk0-x22f.google.com.
As can be seen in the example, the IP rDNS “2607:f8b0:400c:c05::22f” is “mail-vk0-x22f.google.com”.
Importance of rDNS to email servers
Many email providers check the rDNS from source when receiving an e-mail. Although not a standard, if rDNS is not the same as the MTA hostname, the message is rejected by many of these providers. The technique ended up being widely used and for this reason it is important that your mail server has rDNS same to the hostname of the machine.
This technique is a way to restrict access to SMTP services, ensuring that the IP administrator agrees that the machine in question is actually being used with that name. Many IPs do not have rDNS and may therefore be used for purposes other than genuine e-mail service. Sometimes is a residential machine or other types services machine, that can be hijacked by spambot.
How to configure rDNS on your mail server
If you are the administrator of the IP block of your mail server, simply change the DNS zone records in such a way that the rDNS query responds properly, as described above.
If your e-mail server is using an IP from a data-center or ISP, you will need to request the change of rDNS directly to the administrator of this company. If company refuses to change the rDNS of your IP, it may mean that your agreement to use that specific IP is not intended to use in a email server. In this case, it will be necessary to change the IP or establish a new contract. If the company refuses to change rDNS in any situation, the solution is to terminate the contract because this type of configuration should be taken by any serious company in this area.
You must use the hostname of the machine to configure rDNS. Use the following command on your server to find out which machine’s hostname is:
In this example, the hostname of the machine is “mx-br.spfbl.net” and it is exactly this name that should be used in the rDNS of the IP that this machine is using.
If the hostname of the machine is wrong, you must correct it before configuring rDNS:
ubuntu:~$ sudo hostnamectl set-hostname mx-br.spfbl.net
This command will make all the necessary settings to change the hostname and keep it permanent so that the machine can be restarted and continue using the same hostname.