Knowledgebase

How to set up rDNS (PTR) and hostname for a mail server

If you send email from your own VPS or dedicated server, receiving mail servers check that your server IP has a correct reverse DNS (rDNS) record, also called a PTR record, and that it matches the server hostname. Without it, many providers reject your messages or put them in spam. This guide explains how to set up rDNS/PTR and the hostname for a mail server, and how to check them.

Who controls the PTR record? A PTR record belongs to the owner of the IP address, not to your domain's DNS. You cannot add it in your DNS zone. For an EgWeb VPS or dedicated server, open a support ticket with the IP and the hostname you want.

How it fits together

Three records must agree (this is often called forward-confirmed reverse DNS):

  1. The server hostname is a full name, for example mail.example.com or server1.example.com.
  2. An A record for that hostname points to the server IP.
  3. The PTR record of the IP points back to the same hostname.

Step 1: Choose a hostname and create its A record

Pick a subdomain you will not use for a website, such as mail.example.com or server1.example.com. In your DNS zone, add an A record for it with the server IP. See DNS records explained: A, AAAA, CNAME, MX, TXT and NS if you are new to DNS.

Step 2: Set the hostname on the server

Without a control panel:

sudo hostnamectl set-hostname mail.example.com
hostnamectl

It is also good practice to add the name to /etc/hosts:

# /etc/hosts
203.0.113.25   mail.example.com   mail

On a cPanel/WHM server: do not use hostnamectl. In WHM, search for Change Hostname and set the full hostname there, so cPanel updates its own services and certificates.

Step 3: Request the PTR record

Open a ticket (see How to contact support and open a ticket) with:

  • the server IP address (and the IPv6 address if you send mail over IPv6);
  • the hostname you want, which must already have an A record pointing to that IP.

Step 4: Verify

dig +short mail.example.com A        # should return your server IP
dig +short -x 203.0.113.25           # should return mail.example.com.

Both answers must match. DNS changes can take some time to appear everywhere. You can also send a test email to a Gmail address and open Show original to check the result.

Also set SPF, DKIM and DMARC

rDNS alone is not enough for good delivery. Make sure your domain has SPF, DKIM and DMARC records, as explained in Why does my email go to spam? SPF, DKIM and DMARC.

Common problems

  • Bounce messages mentioning "reverse DNS" or "PTR": the PTR record is missing or does not match the A record.
  • The PTR shows a generic name such as the data center's default: the PTR has not been changed yet; ask support.
  • The hostname resolves to another IP: fix the A record first; a PTR request cannot be completed until the A record is correct.
  • The hostname is the same as your website domain: on cPanel servers, use a separate subdomain for the hostname, not the main domain of a hosted site.

Frequently asked questions

Do I need rDNS if I use Google Workspace or Zoho Mail?

No. In that case Google or Zoho send your email from their servers, and they manage rDNS. You only need it when your own server sends mail.

Can one IP have several PTR records?

It is best to have exactly one PTR record per IP, matching the hostname the mail server announces.

Need help? Open a support ticket or message us on WhatsApp +20 127 113 3655.

  • rDNS, PTR, hostname, mail server, email delivery, WHM

Was this answer helpful?

0 Users Found This Useful