Sub topic 6
Reverse DNS and HELO hostname
This chapter assumes you can read a DNS zone, know what an A record and a TXT record are, and have seen an SMTP conversation. You should also have chosen your sending IP and subdomain in the earlier chapters. Here you will make the IP address, its reverse DNS name and the name your server announces all agree with each other.
Why receivers check the connecting IP
When your server connects to a mailbox provider, the receiver knows only your IP address. It looks up that address in reverse DNS, which is the PTR record for the IP. Mail from an IP with no PTR record, or with a generic one such as 203-0-113-25.dynamic.isp.net, looks like it came from a home connection or a compromised machine. Many providers defer or reject it before they look at any content.
Reverse DNS is not a replacement for SPF or DKIM. It is a basic check that the IP has a stable, named owner.
Forward-confirmed reverse DNS
The check that matters is forward-confirmed reverse DNS (FCrDNS). It has three steps:
- The receiver looks up the PTR record of your IP and gets a hostname.
- It looks up the A record of that hostname.
- The A record must return the same IP.
If step 3 fails, the PTR record counts for little. In the earlier example the IP 203.0.113.25 has the PTR name mail.example.com, and mail.example.com has the A record 203.0.113.25.
Who controls the PTR record
You cannot add a PTR record in your own domain's zone. Reverse zones belong to whoever owns the IP block, so the record is set through your hosting provider, cloud console or ESP. On a dedicated IP at an ESP, you usually ask them to set the PTR to a hostname you choose. On a shared IP, the ESP's own hostname is used and you have nothing to configure.
Choose a hostname inside the sending subdomain from the previous chapters. This keeps the name tied to your brand and your reputation. Create its A record in your zone before you ask for the PTR change.
The HELO/EHLO hostname
At the start of every SMTP session, your server says EHLO <hostname>. That name should satisfy three conditions:
- It is a fully qualified domain name, not
localhostor a bare IP. - It resolves by an A record to the sending IP.
- It matches the PTR hostname.
Using the same name for the PTR, the A record and the EHLO line is the simplest way to avoid mismatches. For Postfix, set it like this:
# /etc/postfix/main.cf
myhostname = mail.example.com
smtp_helo_name = $myhostnameIf you use an ESP, it sets the EHLO name for you, and you can skip this step.
Verifying before the first send
Run the dig commands from the code example earlier in this tutorial. The PTR lookup (dig +short -x 203.0.113.25) should return mail.example.com. and the A lookup should return 203.0.113.25. You can also check the greeting your server actually sends:
# The 220 banner shows the name the server announces
openssl s_client -connect mail.example.com:25 -starttls smtp -quiet </dev/null 2>&1 | head -n 5Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Deferrals mentioning "no PTR" or "reverse DNS" | PTR not set | Ask the IP owner to set it |
| PTR is a generic ISP name | Default hostname never changed | Request a custom PTR |
| PTR and A record disagree | A record missing or pointing elsewhere | Fix the A record, wait for TTL |
| EHLO says `localhost` | Server default left in place | Set `myhostname` or the ESP equivalent |
| Several unrelated PTRs on one IP | Provider error | Keep exactly one PTR per IP |
Exercise
Your IP 198.51.100.7 has the PTR name mail.example.net, but mail.example.net has an A record for 198.51.100.8. Does FCrDNS pass, and what do you change?
Show answer
It fails, because the A record of the PTR hostname does not return the connecting IP. Either change the A record of mail.example.net to 198.51.100.7, or ask the IP owner to set the PTR to a hostname whose A record returns 198.51.100.7. Then set the EHLO name to the same hostname.