How to setup Reverse DNS and PTR records
Establish a proper reverse DNS zone to improve email delivery
DNS can be tricky. There is a lot to know and, even when you think you have a firm grasp on it, surprises still pop up. Reverse DNS and PTR record configuration is one of those sneaky topics, but it's crucial to SPAM prevention during email delivery.
For some reason I was unable to find a clear and simple answer out there for how to accomplish this task, so that is my goal with this post. A simple explanation of reverse DNS is that it’s the exact opposite of DNS. Standard (aka forward) DNS maps a domain name to an IP address whereas reverse DNS maps an IP address to a domain name. The two are distinct and separate lookups however. Just because a forward lookup of example.com resolves to 220.127.116.11 doesn’t mean that a reverse lookup of 18.104.22.168 will resolve to example.com.
Reverse DNS: 22.214.171.124 -> ec2-23-23-212-126.compute-1.amazonaws.com.
In the case of ITWorld, the reverse DNS resolves to an Amazon EC2 cloud host which is powering its DNS servers.
Why it’s needed
The most common reason for establishing a reverse DNS is for outbound e-mail servers. Since a reverse DNS record adds further tracing to the origin of an e-mail, it also adds credibility to the e-mail server itself. For that reason, some incoming mail servers will not even consider accepting a message from an IP address which does not identify itself with a PTR record in a reverse DNS zone.
How to do it
A very important thing to note, you must create the reverse DNS zone on the authoritative DNS nameserver for the main IP address of your server. You can find out which nameserver is the authoritative server by entering the IP address you’re trying to configure into the DIG Web Interface. If the Reverse response is not provided by your nameserver, you’ll need to contact your hosting provider to help you set a PTR record. You should be able to accomplish that be emailing their support team and letting them know you’d like a PTR record set for the IP address X.X.X.X resolving to yourdomain.example.com.
If you are in control of the authoritative nameserver, the first step is to create a reverse DNS zone. The hostname for the zone has to be in a very specific format. It starts with a portion of your IP address written backward followed by .in-addr.arpa.
If for example your IP address is 192.168.0.100, you start by dropping the final octet (last set of numbers) to give you 192.168.0
Next, you need to reverse that fragment of the IP address giving you: 0.168.192
Finally, append .in-addr.arpa. leaving you with the completed reverse zone domain of: 0.168.192.in-addr.arpa.
Create the PTR Recrod
Now that you’ve created your zone file you can create the PTR record.
Add a new PTR record and for the name, enter the final digit of the IP address that you’re setting up the reverse record for. In our example, 100. For the Canonical Hostname, enter the domain name you’d like the IP address to resolve to, for instance mailserver.example.com.
After you’ve saved your zone file, allow some time for the change to propagate before validating the new reverse DNS record. If everything went properly, you should see something like the following the next time you run the DIG Web Interface Tool:
126.96.36.199.in-addr.arpa. 6230 IN PTR mailserver.example.com.