WESERVER / KNOWLEDGE BASE

What is a reverse DNS (PTR) record and why does a server need one?

A PTR record maps an IP address back to a hostname and answers reverse DNS lookups. It is set by the provider that owns the IP address, not in your domain’s DNS panel. Servers that send email need one.

Short answer

A reverse DNS (PTR) record is the DNS record that tells you which hostname an IP address belongs to. A and AAAA records turn a domain name into an IP address; a PTR record works the other way round and answers mail.example.com when someone asks about 203.0.113.10.

If your server sends email, it needs a PTR record. Receiving mail servers look up the PTR record of the connecting IP; if there is none, or the name it points to does not resolve back to the same IP, the message is rejected or lands in spam. A machine that only runs a website, a VPN or a game server does not strictly need one, but you can still set it so logs and traceroute output show a readable name.

What is a reverse DNS (PTR) record? Fix rejected and spam mail

How does a PTR record work? (in-addr.arpa and ip6.arpa)

The PTR record is an old DNS record type defined in RFC 1035. For a reverse lookup, the IP address is turned into a special domain name. In IPv4 the parts of the address are written in reverse order with in-addr.arpa added at the end, so the PTR record for 203.0.113.10 lives at 10.113.0.203.in-addr.arpa.

IPv6 does the same under ip6.arpa (RFC 3596). The address is first expanded to all 32 hex digits, without dropping zeros, then the digits are written one by one in reverse order with dots between them. That is why 2001:db8::10 becomes a long name like 0.1.0.0.0.0.0.0 … 8.b.d.0.1.0.0.2.ip6.arpa. You never have to type it by hand; dig -x does the conversion for you.

The reverse zone belongs to whoever owns the IP block. When a regional internet registry assigns a block to a provider, it also delegates that block’s in-addr.arpa or ip6.arpa zone to the provider’s DNS servers. So where you manage your domain’s DNS has no effect on the PTR record.

Why does a server need a PTR record?

  • Email delivery: receiving servers check the PTR record of the sending IP. Google’s email sender guidelines require valid forward and reverse DNS records for the sending IP. Without one, Gmail refuses the message with “550-5.7.25 The IP address sending this message does not have a PTR record setup”.
  • Server identity: a generic name the provider assigns automatically, such as 203-0-113-10.static.provider.net, looks like the dynamic addresses on home connections. Some spam filters treat names like that as suspicious. A name under your own domain, such as mail.example.com, shows clearly who the IP belongs to.
  • Readable logs and network tests: traceroute, mtr and server logs show the hostname instead of the IP for addresses that have a PTR record. When you describe a network problem to a support team, it is immediately clear which server you mean.
  • Connection delays: with UseDNS yes in OpenSSH, the server tries to reverse-resolve the connecting client’s IP. If that lookup times out, the SSH login hangs for a few seconds. Current OpenSSH releases have this setting off by default.

Who sets the PTR record, and how do you change it?

The provider that owns the IP address sets the PTR record. Creating a PTR-type record in Cloudflare or your registrar’s panel does nothing, because reverse lookups never reach that panel. If your provider’s client panel has an “rDNS” or “Reverse DNS” field, enter the record there; if not, send the IP address and the hostname you want to the support team.

To get a PTR record set for a server at WeServer, send the IP address and hostname to the support team through the channel on the contact page. Before you ask, point that hostname’s A record (AAAA for IPv6) at the same IP; a PTR that names a host with no forward record fails the check described below.

The name in the PTR has to be genuine. WeServer’s acceptable use policy prohibits misleading information in reverse DNS, WHOIS and other network records. Putting another company’s hostname, or a domain you do not own, in a PTR record falls under that rule.

How do you choose the right PTR record? (FCrDNS check)

Mail servers also check whether the PTR record matches the forward record. This is called forward-confirmed reverse DNS (FCrDNS): the IP’s PTR record returns a name, and that name’s A or AAAA record must point back to the same IP. Set up a sending server in this order:

  • Pick a hostname: a name specific to the server under your own domain, such as mail.example.com. You can use your bare domain (example.com) as the PTR, but it gets confusing when the site and the mail run on different servers.
  • Create the forward record: in your domain’s DNS panel, add an A record for mail.example.com pointing at the server’s IPv4 address, and an AAAA record if mail will go out over IPv6.
  • Get the PTR set: through the provider’s panel or support team, request a PTR record of mail.example.com for the same IP. Keep one PTR record per IP; several names on one IP make the check give inconsistent results at some receivers.
  • Match the name the server announces: set the system name with hostnamectl set-hostname mail.example.com. If you use Postfix, put myhostname = mail.example.com in /etc/postfix/main.cf and run systemctl reload postfix. Some receivers also compare the HELO/EHLO name with the PTR and the forward record; the setup is simplest when all three match.
  • Add the remaining records: a PTR alone does not get mail delivered. You also need SPF, DKIM and DMARC records, and Google’s guidelines require those too.

How do you check a PTR record?

On Linux, the commands below come with the dnsutils package (Ubuntu and Debian) or bind-utils (AlmaLinux and Rocky Linux). Replace 203.0.113.10, 2001:db8::10 and mail.example.com in the examples with your own values:

  • dig -x 203.0.113.10 +short: prints the PTR record of the IPv4 address. Empty output means there is no record.
  • dig -x 2001:db8::10 +short: runs the same check for an IPv6 address; dig builds the ip6.arpa name itself.
  • dig +short A mail.example.com and dig +short AAAA mail.example.com: return the forward record of the name the PTR points to. The IP here must be the same one you asked about in the first command.
  • host 203.0.113.10: shows the PTR record on one line as “domain name pointer mail.example.com.”.
  • nslookup 203.0.113.10 on Windows: the Name line shows the name in the PTR record.
  • dig -x 203.0.113.10 @1.1.1.1 +short: sends the query to an outside resolver instead of the one on your server. If the record was just changed and the results differ, the old record is still cached; the new name shows up once the TTL expires.

What errors appear when the PTR is missing or wrong?

  • “550-5.7.25 The IP address sending this message does not have a PTR record setup” from Gmail. Cause: the sending IP has no PTR record or fails the FCrDNS check. Fix: check the PTR with dig -x and the name’s forward record with dig +short A; adjust the records until both meet at the same IP.
  • “450 4.7.25 Client host rejected: cannot find your hostname” from a receiver running Postfix. Cause: the receiver found no PTR record for your IP, or the name it found does not resolve back to your IP. Fix: the same FCrDNS check; if the record is new, wait for the TTL to expire.
  • Mail goes through over IPv4 but is rejected over IPv6. Cause: the PTR record exists only for the IPv4 address, and the server is sending over IPv6. Fix: get AAAA and PTR records for the IPv6 address too, or pin sending to IPv4 in Postfix with inet_protocols = ipv4.
  • The PTR is correct but mail still goes to spam. Cause: SPF, DKIM or DMARC is missing, or the IP address is on a spam blocklist. Fix: add the missing records and check the IP’s reputation with blocklist lookup tools.
  • SSH waits a few seconds before asking for the password. Cause: UseDNS yes is set in sshd_config and the reverse lookup of the client IP times out. Fix: set UseDNS no and run systemctl reload ssh (sshd on AlmaLinux and Rocky Linux).

Frequently asked questions

Can I add a PTR record in my domain’s DNS panel? No. Reverse lookups go to the DNS servers of the provider that owns the IP block. You get the PTR record set through the provider’s panel or its support team.

Can one IP address have more than one PTR record? DNS allows it, but mail servers cannot tell which name will come back, so the check becomes inconsistent. Keep one PTR record per IP.

Do I need a PTR for every address in an IPv6 Subnet VDS block? No. A /64 or /48 block holds billions of addresses; PTR records are set only for addresses that send mail or need to be recognised by name. The reputation reasons for giving a mail server its own address and PTR are in “IPv6 /48 vs /64 subnet: what is the difference and which should you choose?”.

When does a PTR change take effect? When the TTL of the old record in the reverse zone expires. If different resolvers give different answers in dig -x, that wait is not over yet.

Does a server that does not send mail need a PTR? It is not required. Set one if you want to see the server by name in logs and traceroute output. First steps for a new server are in “How to secure a new VDS: first security steps”.

Browse related productsAsk on WhatsApp← Back to category

RELATED

Related articles

ALL IN WE1

Let’s build your infrastructure together.

Share your requirements and we will help you choose the right resources and server type.

Chat on WhatsApp