Back to tutorials
Tutorial

VPS reverse DNS setup tutorial (2026): Configure PTR records for email deliverability and hostname checks

VPS reverse DNS setup tutorial (2026) to configure PTR records, fix HELO/FCrDNS checks, and improve email deliverability.

By Anurag Singh
Updated on Aug 06, 2026
Category: Tutorial
Share article
VPS reverse DNS setup tutorial (2026): Configure PTR records for email deliverability and hostname checks

Email from a new VPS often fails for a simple reason: your sending IP has no proper reverse DNS. This VPS reverse DNS setup tutorial shows how to set PTR records correctly, verify forward-confirmed reverse DNS (FCrDNS), and stop common “hostname does not resolve” bounces before customers see them.

What you’ll set up (and why it matters)

Reverse DNS maps an IP address back to a hostname using a PTR record. Many mail receivers use it as a fast sanity check.

If your IP claims “mail.example.com” in reverse DNS, receivers expect “mail.example.com” to resolve back to that same IP.

That forward-and-reverse match is called FCrDNS. Passing it won’t guarantee inbox placement. Failing it often causes:

  • Hard bounces on strict domains (some enterprise gateways don’t negotiate).
  • Spam-folder placement because a new IP starts with low trust.
  • HELO/EHLO hostname warnings from receiving MTAs.

If you host email for clients, rDNS is mandatory.

If you only send transactional mail from apps, it still matters. It’s especially important during IP warmup.

Prerequisites for this VPS reverse DNS setup tutorial

  • A VPS or dedicated server with a static IPv4 (and optionally IPv6).
  • A domain name you control (example.com).
  • Ability to set DNS A/AAAA records for the hostname you’ll use (mail.example.com).
  • Provider access to set PTR (usually via a panel or a support ticket).

If you’re building an email-capable VPS for client hosting, prioritize stable networking and a clean IP range.

A HostMyCode VPS gives you the static addressing you need for predictable PTR setup and mail reputation.

Step 1: Pick the correct mail hostname

Pick a hostname you can keep for the long haul. Avoid names that look temporary or tied to one app.

  • Good: mail.example.com
  • Also fine: smtp.example.com
  • Avoid: server123.example.com (it reads as disposable)

Set your server’s system hostname to match.

On Ubuntu/Debian:

sudo hostnamectl set-hostname mail.example.com
hostnamectl status

On AlmaLinux/Rocky:

sudo hostnamectl set-hostname mail.example.com
hostname -f

Quick check:

hostname -f

You want it to return mail.example.com.

Step 2: Create forward DNS (A/AAAA) for the hostname

Get forward DNS right before you touch PTR.

Start by creating an A record:

  • Host: mail
  • Type: A
  • Value: your IPv4 address (example: 203.0.113.10)
  • TTL: 300–900 seconds while you’re setting up; increase later

If you have IPv6, add an AAAA record too:

  • Host: mail
  • Type: AAAA
  • Value: your IPv6 address

Once DNS propagates, test from your workstation or the server:

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

If you’re also moving DNS as part of a hosting change, follow HostMyCode’s step-by-step DNS migration tutorial. It helps you avoid the classic “site works but mail breaks” outcome.

Step 3: Set the PTR record (reverse DNS) for your IP

You can’t set PTR records in your normal domain DNS zone unless you own the IP block.

In most hosting setups, your provider controls reverse DNS for the address you lease.

Set the PTR value to the hostname you chose:

  • IP: 203.0.113.10
  • PTR (rDNS): mail.example.com

After it’s applied, verify the reverse lookup:

dig +short -x 203.0.113.10

Expected output:

mail.example.com.

If you’re setting this up on a hosting server that serves multiple domains, keep expectations realistic.

One IP typically maps to one PTR, and that’s normal.

Your clients don’t need separate PTR records as long as your outbound identity is consistent and your SPF/DKIM/DMARC are correct.

Step 4: Validate FCrDNS (forward-confirmed reverse DNS)

This is the check many receivers run: “PTR points to a hostname, and that hostname resolves back to the same IP.”

Test both directions.

# Reverse: IP -> hostname
PTR=$(dig +short -x 203.0.113.10 | head -n1 | sed 's/\.$//')
echo "$PTR"

# Forward: hostname -> IP
dig +short A "$PTR"

That final A lookup must return 203.0.113.10.

If it doesn’t, fix the A record first.

A broken chain often looks worse than missing rDNS because it signals a misconfigured sender.

For IPv6, do the same with AAAA:

dig +short -x 2001:db8::10
dig +short AAAA mail.example.com

Step 5: Align your mail server’s HELO/EHLO with rDNS

Receivers compare your SMTP greeting name to your rDNS and your forward DNS.

If your MTA announces itself as localhost or a default name, you’ll see warnings, reputation damage, and occasional blocks.

Postfix (common on Ubuntu/Debian)

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

Exim on cPanel/WHM

In WHM: Service Configuration → Exim Configuration Manager

  • Set the Primary Hostname of the server to mail.example.com in WHM.
  • Verify it resolves and matches the PTR.

If you run cPanel, keep updates predictable. Also test mail flow after patching.

HostMyCode’s cPanel server update tutorial outlines a safe routine that avoids breaking client sites.

Step 6: Confirm your PTR matches your TLS and DNS identity

rDNS is only one signal. Receivers also look for a server that behaves like a legitimate mail host:

  • Your SMTP banner/HELO matches your hostname.
  • Your hostname has an A/AAAA record matching your sending IP.
  • Your outbound mail uses SPF/DKIM/DMARC aligned to your From domain.
  • Your server offers modern TLS and a valid certificate on submission (587) if you provide authenticated SMTP.

For the DNS authentication side, follow the practical checks in Email deliverability troubleshooting.

If you need to build DMARC carefully, use the DMARC setup tutorial to roll out a policy without accidentally rejecting legitimate mail.

Step 7: Test from the outside (real recipient behavior)

Don’t stop at DNS lookups. Send a test message to mailboxes you control (Gmail, Outlook, and a corporate domain if you can).

Then review the headers for:

  • Received lines showing your HELO name
  • SPF/DKIM/DMARC pass
  • No “reverse DNS missing” notes

If you’re starting from a fresh IP, ramp volume slowly and consistently.

Sending patterns matter as much as configuration.

HostMyCode’s VPS email warmup tutorial gives you a schedule that avoids the “day one blast” mistake.

Common reverse DNS problems (and fixes that actually work)

Problem: PTR is set, but FCrDNS fails

Symptom: dig -x returns your hostname, but your hostname doesn’t resolve back to the same IP.

Fix: Correct the A/AAAA record for the PTR hostname.

If you recently changed IPs, flush old DNS values.

Also confirm your authoritative nameservers are the ones you intended.

Problem: PTR points to the provider’s default name

Symptom: PTR shows something like vps-203-0-113-10.provider.net.

Fix: Update PTR to your mail hostname.

If you can’t edit it in a panel, send support the exact mapping: “203.0.113.10 → mail.example.com”.

Problem: Multiple outgoing IPs, but only one PTR configured

Symptom: Your MTA sometimes sends from a secondary IP without matching PTR.

Fix: Pin outbound mail to the IP you’ve prepared (recommended), or set PTR for every sending IP.

On Postfix, check:

postconf -n | egrep 'smtp_bind_address|inet_interfaces|myhostname'

If you’re on a cPanel server with extra IPs, confirm the account’s outbound IP assignment.

Avoid “random” egress addresses.

Problem: Bounces mentioning “HELO/EHLO” or “hostname does not resolve”

Fix: Make sure the MTA announces mail.example.com.

Confirm mail.example.com has an A record and that the PTR matches. Then retest.

Problem: You changed the server’s hostname, but mail still announces the old one

Fix: Restart the MTA and confirm it’s reading the updated config.

For Postfix:

sudo systemctl restart postfix
postconf myhostname

For Exim on cPanel/WHM, confirm the WHM primary hostname and restart Exim from WHM or via:

/scripts/restartsrv_exim

Operational checklist (save this for your next VPS build)

  • Pick a stable hostname: mail.example.com
  • Set system hostname: hostnamectl set-hostname
  • Create A/AAAA records for the hostname to your sending IP(s)
  • Set PTR for the IP to the hostname
  • Validate FCrDNS: A ↔ PTR match
  • Align HELO/EHLO with the hostname
  • Add SPF/DKIM/DMARC for the From domain(s)
  • Warm up sending if the IP is new
  • Monitor bounces and queues during the first week

Security and reliability notes for mail on a hosting VPS

Email punishes small mistakes.

One bad firewall rule can block SMTP, break Let’s Encrypt challenges, or leave submission ports exposed without rate limits.

Keep your port policy explicit, and test from outside your own network.

If you suspect firewall rules are blocking mail or certificate renewals, use VPS firewall troubleshooting to diagnose the problem without locking yourself out.

For long-lived hosting servers, consider managed VPS hosting if you’d rather hand off OS updates, service health checks, and recovery support to an ops team.

It’s usually cheaper than chasing a mail outage under pressure.

If you’re setting up email on a new server, start with stable IP addressing and DNS you can control. A HostMyCode VPS gives you a solid base for PTR records, SMTP reputation, and clean hostname configuration. If mail is business-critical, managed VPS hosting helps keep patching, monitoring, and recovery routines consistent.

FAQ

How long does reverse DNS (PTR) take to update?

Many providers apply PTR changes within minutes, but caching can make results look stale for a few hours.

If you see inconsistent answers, run dig -x from more than one network.

Can I set multiple PTR records for one IP?

Some DNS setups allow it, but it’s a bad idea for email. Most receivers expect a single, stable PTR. Use one hostname per sending IP.

Do I need rDNS if I only use an external SMTP service?

No. If you relay outbound mail through a third-party SMTP provider, their IP reputation and rDNS are what matter.

You’ll still want a proper hostname for your server, but PTR won’t block relayed mail.

Does reverse DNS fix spam folder issues by itself?

No. It fixes a common trust failure, but inbox placement still depends on SPF/DKIM/DMARC, content, complaint rate, and sending patterns—especially on new IPs.

Summary: make rDNS boring, then move on

The goal isn’t to “optimize” reverse DNS.

You want it correct and forgettable: one PTR, one hostname, one matching A/AAAA record, and an SMTP identity that lines up.

Once FCrDNS passes, shift your attention to authentication, warmup, and monitoring.

If you’re building or migrating a mail-capable server in 2026, choose infrastructure that supports stable addressing and quick PTR updates.

A HostMyCode VPS or managed VPS hosting setup keeps basics like rDNS under your control, which is where reliable email starts.