Back to tutorials
Tutorial

Reverse DNS Setup Tutorial (2026): Configure rDNS on a VPS for Better Email Deliverability

Reverse DNS setup tutorial for 2026: configure rDNS on a VPS, align SPF/DKIM, and reduce “spam” bounces.

By Anurag Singh
Updated on Oct 07, 2026
Category: Tutorial
Share article
Reverse DNS Setup Tutorial (2026): Configure rDNS on a VPS for Better Email Deliverability

Email deliverability issues on a VPS often come down to one detail: reverse DNS. If your sending IP doesn’t map back to a hostname, expect bounces like “No PTR record.” If that hostname doesn’t resolve forward to the same IP, expect “Reverse DNS mismatch” or “Bad HELO.” This reverse DNS setup tutorial shows a clean, 2026-safe setup that works with Postfix, Exim, and cPanel/WHM-hosted mail.

You’ll set a PTR record (rDNS) and align forward DNS (A/AAAA). You’ll also confirm your server hostname and verify everything with real commands. No hand-waving, and no “close enough.”

What you’ll build (and why rDNS matters)

Reverse DNS is a PTR record tied to an IP address. Many receiving mail systems use it as a basic trust check, especially for new IPs and smaller senders.

A correct setup won’t guarantee inbox placement. A broken setup can trigger rejections, throttling, or spam-folder scoring.

  • PTR (rDNS): Your sending IP → mail.example.com
  • Forward DNS: mail.example.com → your sending IP (A/AAAA)
  • SMTP banner/HELO: your MTA introduces itself as mail.example.com

If those pieces don’t agree, you’ll feel it. Expect graylisting delays, stricter rate limits, “bad HELO” bounces, and extra spam points.

Prerequisites (10-minute checklist)

  • A VPS or dedicated server with a static public IPv4 (IPv6 optional but recommended if you send over v6).
  • Root/sudo access.
  • A domain you control (example: example.com).
  • Ability to edit DNS at your DNS provider (or your registrar).
  • Ability to set rDNS/PTR in your hosting control panel (most hosts provide this in the client area) or by support request.

If you’re building a mail-capable VPS from scratch, HostMyCode VPS plans are a clean fit. You get dedicated resources, static IP options, and the control you need for DNS and mail tuning.

Step 1: Pick the correct hostname for PTR (don’t use the root domain)

Your PTR should point to a mail-specific hostname, not your main website. In 2026, the least controversial choices are:

  • mail.example.com (recommended)
  • smtp.example.com (also fine)

Avoid using example.com itself unless you have a specific reason. It often overlaps with web/CDN setups.

Backing it out later is rarely fun.

Step 2: Set your server’s system hostname (Ubuntu/Debian/AlmaLinux/Rocky)

Your system hostname should match the mail hostname you’ll use for PTR. First, check what your server currently reports:

hostnamectl
hostname -f

Set it (example uses mail.example.com):

sudo hostnamectl set-hostname mail.example.com

Next, make sure /etc/hosts maps the hostname to your server’s primary IP. On most VPS deployments, you want your public IPv4 here.

Don’t point it at 127.0.1.1.

sudo nano /etc/hosts

Example (adjust IP and hostname):

203.0.113.10   mail.example.com mail
127.0.0.1      localhost

Pitfall: if your hostname resolves to 127.0.1.1, some MTAs announce the wrong name. Others fail HELO sanity checks.

Step 3: Create forward DNS (A/AAAA) for your mail hostname

At your DNS provider, add:

  • A record: mail.example.com → 203.0.113.10
  • AAAA record (if you have IPv6): mail.example.com → 2001:db8::10

During setup, keep TTL reasonable (300–900 seconds) so fixes propagate quickly.

Once things are stable, raise it.

If you want a careful walkthrough for DNS changes and avoiding propagation surprises, you can reference this MX record setup tutorial for the broader “don’t break mail flow” rules. We’re focusing on PTR here, but the DNS hygiene is the same.

Step 4: Request or set PTR (reverse DNS) for your sending IP

This is where a lot of setups go wrong. PTR isn’t configured in your normal DNS zone.

The PTR lives with whoever controls the IP block. That’s usually your hosting provider.

Set the IP’s PTR to the exact hostname you chose. Example:

  • IP: 203.0.113.10
  • PTR: mail.example.com

On managed services, you’ll typically open a support request.

If you’d rather not chase rDNS updates during migrations or IP swaps, managed VPS hosting is a practical option. You keep control, but you’re not stuck waiting on internal provider handoffs.

Step 5: Verify forward and reverse alignment (real commands)

Give DNS a few minutes, then validate from your server (or any Linux host). Install lookup tools if needed:

# Ubuntu/Debian
sudo apt-get update && sudo apt-get install -y dnsutils

# AlmaLinux/Rocky
sudo dnf install -y bind-utils

Check forward DNS:

dig +short mail.example.com A
dig +short mail.example.com AAAA

Check reverse DNS (PTR):

dig +short -x 203.0.113.10

Now confirm the round trip (forward-confirmed reverse DNS).

This should return your original IP:

dig +short $(dig +short -x 203.0.113.10) A

You want:

  • PTR returns mail.example.com.
  • mail.example.com resolves back to 203.0.113.10

Quick diagnostic: if PTR returns a different hostname than your server announces in HELO, fix HELO next.

Step 6: Ensure your MTA uses the same hostname in HELO/EHLO

PTR can be perfect and you can still get “Bad HELO” or “HELO does not match PTR.” Receivers compare your SMTP greeting with what your IP reverse-resolves to.

Make them match.

Postfix (common on Ubuntu/Debian)

Check your current identity:

postconf -n | egrep 'myhostname|mydomain|myorigin'

Set myhostname to your mail hostname:

sudo postconf -e 'myhostname = mail.example.com'
sudo systemctl restart postfix

If you want a focused bounce-fixing flow, see SMTP HELO/EHLO hostname fix tutorial.

Exim (common on cPanel/WHM)

On cPanel, the server hostname is typically managed in WHM under Networking Setup → Change Hostname. Set it to the same name used by your PTR.

After you change it, cPanel updates multiple services to follow suit.

If you’re running WHM, pair this with control panel hardening steps for cPanel/WHM. Compromised accounts and brute-force noise can drag down mail reputation fast.

Step 7: Align the rest of your deliverability basics (SPF, DKIM, DMARC, rDNS, TLS)

PTR is only one part of the picture. If your VPS sends business mail or customer mail, you also need authentication.

Keep the records simple, correct, and aligned.

  • SPF: authorizes your sending IPs
  • DKIM: cryptographically signs outbound mail
  • DMARC: tells receivers how to enforce SPF/DKIM and where to report

If you’re using WHM-managed DNS, follow this cPanel SPF/DKIM/DMARC setup guide. It’s tuned for real WHM setups, where a single wrong include can break mail across multiple domains.

Practical alignment rule: include your VPS IP in SPF and have DKIM sign with the same domain used in the From: header. DMARC only helps once SPF/DKIM alignment is actually working.

Step 8: Test from the command line (SMTP banner + reverse lookup)

From another machine (or your laptop), check what your server presents during an SMTP connection. Replace the hostname as needed.

openssl s_client -starttls smtp -connect mail.example.com:25 -crlf

Look for:

  • A certificate that matches your mail hostname (or at least a valid chain)
  • A banner hostname that matches mail.example.com

If TLS negotiation fails or the chain is wrong, fix issuance and renewal first.

For a general TLS workflow across Nginx/Apache and common renewal errors, see this SSL certificate setup guide.

Step 9: Common rDNS problems (and the exact fix)

Your VPS IP changed after migration

If you moved to a new VPS and your IP changed, the old PTR no longer applies. Update the PTR for the new IP.

Also make sure mail.example.com points to that new IP.

Use low TTLs during cutovers and test before you flip anything permanent.

If you’re moving mailboxes, sync them first and touch DNS last. DNS-first migrations are how “an hour of downtime” becomes two days of cleanup.

PTR points to a generic host name

Some providers default PTR to something like vps-203-0-113-10.provider.net. That isn’t always fatal, but it often lowers trust.

It also commonly triggers HELO mismatch if your server announces mail.example.com.

Fix: change PTR to mail.example.com and keep it stable.

Multiple PTR records (rare, but painful)

An IPv4 address should normally have a single PTR record. Multiple PTRs can confuse receivers and break forward-confirmed reverse checks.

Fix: remove the extras and keep one PTR that matches your MTA identity.

IPv6 sending without matching PTR

If your server prefers IPv6 and you publish AAAA records, some receivers will see mail coming from the IPv6 address.

If that IPv6 address has no PTR, deliverability can turn inconsistent.

Fix options:

  • Set IPv6 PTR to the same hostname (recommended)
  • Temporarily disable IPv6 outbound mail for the MTA until PTR is correct (only if you understand the impact)

Step 10: A fast validation checklist you can reuse

  • [ ] Server hostname: hostname -f returns mail.example.com
  • [ ] Forward A: mail.example.com → your IPv4
  • [ ] Forward AAAA (optional): mail.example.com → your IPv6
  • [ ] Reverse PTR: your IP → mail.example.com
  • [ ] Forward-confirmed reverse: PTR hostname resolves back to the same IP
  • [ ] MTA HELO/banner matches PTR hostname
  • [ ] SPF includes the sending IP; DKIM signs; DMARC policy is present

Operational tips for hosting providers and resellers

If you host multiple customer domains on one VPS, use one stable mail hostname per server. For example: mail.yourbrand.tld. Point PTR to that hostname.

Customers can still send as their own domains. You just need SPF/DKIM/DMARC per domain.

Don’t treat rDNS as “set it once and forget it.” If you rotate IPs because of abuse events, provider changes, or migrations, update PTR in the same change ticket.

Add it to your runbook and your cutover checklist.

Summary: the clean 2026 rDNS pattern

For a mail-sending VPS, the lowest-drama pattern is simple. Pick one mail hostname.

Point forward DNS to the sending IP. Point PTR back to that same hostname. Then make your MTA announce it.

After that, SPF/DKIM/DMARC and basic queue hygiene can do their work.

If you want a VPS built for hands-on DNS and mail control, start with a HostMyCode VPS. If you’d rather have a team handle the knobs during cutovers and IP changes, managed VPS hosting is the calmer route.

If you’re cleaning up deliverability or moving mail to a new server, HostMyCode supports that workflow well. Run your mail stack on a HostMyCode VPS, or choose managed VPS hosting if you want help with rDNS changes, hostname alignment, and safe DNS cutovers.

FAQ

How long does it take for rDNS (PTR) changes to propagate?

Often 5–30 minutes, sometimes a few hours. PTR caching depends on the resolver. If you can, validate with dig -x from more than one network.

Can I set PTR records at my domain registrar?

No. PTR is controlled by the IP owner (your hosting provider). You set A/AAAA in your DNS zone; your host sets PTR for the IP.

Should PTR match the domain in my From: address?

Not required. PTR should match the server’s mail hostname (the HELO/banner identity). Your From: domain should pass SPF/DKIM/DMARC alignment.

Do I need rDNS if I only receive mail (no outbound)?

It matters far less. Receivers typically enforce rDNS on inbound SMTP connections. If your server never sends mail out to the internet, rDNS isn’t a priority.

What’s the quickest way to spot an rDNS mismatch causing bounces?

Look at the bounce text for “PTR,” “reverse DNS,” or “HELO.” Then run dig -x and confirm your SMTP banner/HELO matches the PTR hostname.