PTR Records and Why They Matter for Emails
Tags: email, tutorial, webdev
Published: 2022-12-01 16:19:10

Sorted out authentications? Check. Built a domain reputation? Check. Avoided spam filters at all costs? Check. The list of things for improving deliverability goes on and on. Let’s add one more thing to the list then because PTR records can make a difference too. What are they about? How do you add them properly? Let’s see!

## What are PTR Records?
PTR records (short for Pointer Records) are used to perform a Reverse DNS lookup. 

As you probably know, DNS (Domain Name System) is sort of a phonebook for the Internet. It stores an enormous amount of information about millions of registered domains. To access its (virtual) pages, you need to perform a DNS lookup of a given domain.

This is typically done by browsers right after you type in an email address. With a DNS lookup, they can quickly understand that the /blog/ address actually represents the 3.215.223.38 IP address. This result is called an ‘A Record’. 

A PTR Record is obtained in the opposite fashion. By performing a Reverse DNS lookup, a server can resolve an IP address to obtain a domain or a hostname.

![dns ptr record](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vg6p425fslzetvjwhef6.png)

## Why PTR records are important?
An email travels across the servers (MTAs) on the way to the recipient’s email client. Before it’s delivered to an inbox, most email providers will enforce one simple test. They’ll run a DNS lookup simultaneously with a Reverse DNS lookup and will compare whether the results match. If they don’t or a PTR record simply doesn’t exist, an email is likely to be sent to spam or even discarded.

PTR Records are a defense used by servers against spammers, especially those using fraudulent domain names (let’s say, mailtrop.io). If the records are configured for mailtrap.ip, resolving an IP address with a PTR lookup (Reverse DNS lookup) won’t point to a real domain. This, as a result, will send up a red flag for an MTA and will likely lead to an email being discarded.

That’s why it’s important to have a PTR record added to your domain’s DNS if you use it to send mass emails. 

PTR records are also important for marketers and for their analytical tools, such as Google Analytics. As a website owner, you can easily see which IP addresses visit your pages. The numbers themselves would be rather meaningless but thanks to Reverse DNS lookup you can see the hostnames or domains of visitors. And this can give you some valuable information.

Let’s now learn how to add a PTR record to a domain’s DNS.

## How to set up PTR records?
Same as when you add a regular A record, the steps for adding a PTR record also very much depend on your hosting provider. For some, you should be able to add one in your admin panel. For others, you might need to reach out to the support team so they can set this up for you. We’ll assume you’re able to add PTR Records yourself.

To do so, you’ll first need to define a Reverse zone. By definition, a zone is a separate portion of a domain name space in DNS. A zone is directly related to the size of your IP network. Mailtrap’s IP (3.215.223.38) uses a traditional IPv4 protocol (using an X.X.X.X structure) so there are 255 IP addresses available – 3.215.223.1, 3.215.223.2 and so on until 3.215.223.255.

Since we need an address for the entire zone, we omit the last digit and reverse the order of numbers. The address of our PTR record would be 223.215.3.in-addr.arpa. If we were to create a PTR record only for one single address, we would use 38.223.215.3.in-addr.arpa.

What’s up with in-addr.arpa in each address? It’s a second-level domain suffix that’s added to all the addresses in IPv4. If you were to use a more common IP in the IPv6 system, a PTR Record’s address would end with ip6.arpa.

Add a PTR record following these rules. Then, check if there’s a match. Mailtrap.io should point to 3.215.223.38 (A record) while 38.223.215.3.in-addr.arpa should point to Mailtrap.io (PTR record). If this is the case for your domain’s DNS, you can say you’ve reached a Forward-confirmed reverse DNS (FCrDNS).

A PTR record should look like this:

![dns ptr](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x95wmvzedqebrrhv1m2l.png)

## Can I have multiple PTR records?
By definition, a PTR record can only point to one hostname. But what if you want to have multiple PTR records for a single IP address? This could work when you have several domains registered, each pointing to the same IP address (and displaying the same website when entering an address). To get the PTR records right, you’ll want to resolve this IP address for each of these domains – otherwise, you won’t have a match. 

DNS doesn’t restrict the number of entries you can have but having multiple PTR records is not recommended. Software running mail servers often expect only a single entry for each IP address. When it retrieves it, it starts treating it as a canonical name for a given hostname. As a result, if multiple PTR records are defined for a single IP address, during a Reverse DNS lookup, a server may just pick one at random. And that one might not necessarily match the A record.

When adding MX records to DNS, you can specify their priority. No such feature is available for PTR records.

As a result, adding multiple PTR records for an individual IP doesn’t make you look any more credible in the virtual eyes of ISPs. Quite the opposite, in fact, it might result in a failed verification of A/PTR records and lower the chance of your email getting delivered.

I hope our guide on how to [create PTR record](https://mailtrap.io/blog/ptr-record/) was useful for you. The article was initially published in the Mailtrap blog.