GoAdmio

reversedns

Compare the server's hostname with the reverse DNS (PTR) record of its public IPv4 address and report whether they match

On this page: Overview · Quick start · Syntax · Options · Output · Examples · Troubleshooting · Details · See also


Overview

Reverse DNS (rDNS) is the opposite of a normal DNS lookup: it finds the name that belongs to an IP address, using a PTR record. Mail servers check it. If the PTR record of the IP that sends your mail doesn't match your server's hostname, many providers treat the mail as spam or reject it.

/go/reversedns checks this for you. It:

The command only reports. It changes nothing. The PTR record is set by whoever owns the IP address (usually your hosting provider), not on this server. See Fixing a mismatch.


Quick start

/go/reversedns

Syntax

/go/reversedns
Form Behavior
/go/reversedns Compares the hostname with the PTR record and prints the result.

Options

This command has no options. Arguments are only written to the log file.


Output

Outcome What you get
Match One line: Reverse DNS: <name>
Mismatch Three lines: Hostname: <hostname>, Reverse DNS: <name>, and Reverse DNS Mismatch.

Example of a match:

Reverse DNS: server.example.com

Example of a mismatch:

Hostname: server.example.com
Reverse DNS: static.203-0-113-10.provider.net
Reverse DNS Mismatch.

If the IP address has no PTR record at all, the name is replaced by an odd value, 3(NXDOMAIN, which means "not found":

Hostname: server.example.com
Reverse DNS: 3(NXDOMAIN
Reverse DNS Mismatch.

[!NOTE] The command ends with exit status 0 whether the names match or not. In scripts, read the output (look for Reverse DNS Mismatch.) instead of relying on the exit status.

Every run is also recorded in /var/log/go/reversedns.log.


Examples

# Check the reverse DNS of this server
/go/reversedns
# Check by hand: the PTR record of an IP address
host 203.0.113.10
# Check by hand: the address that a name points to
host server.example.com

Troubleshooting

Symptom Likely cause Fix
Reverse DNS: 3(NXDOMAIN The IP address has no PTR record. Ask your hosting provider to set one (see Fixing a mismatch).
The reverse name is a generic provider name The provider's default PTR record is still in place. Set the PTR record to your server's hostname.
Mismatch right after you changed the record The old answer is cached until its TTL expires. Wait, then run the command again.
The two names look the same but a mismatch is reported The comparison is exact and case-sensitive, or there are several PTR records and all of them are compared as one text. Compare the output of host <ip> with the hostname exactly. Keep one PTR record, in lowercase.
The IP address is not the one you expect The address comes from an internet lookup, so a server behind NAT or a proxy shows the public address, not the server's own. Check the correct address with host, or fix the network setup.
Strange text instead of a name, or usage messages The internet lookup of the IP address failed, or the host tool is missing. Check the server's internet access, and install host (from the bind-utils or dnsutils package).
The command is slow The lookups have no time limit. Check the server's internet access and DNS resolver. See resolver.
Names match, but mail is still rejected Other checks fail: the hostname's own DNS record, SPF, DKIM, or DMARC. See troubleshoot and checkdkim.

Details

How it works

  1. Writes the command and its arguments to /var/log/go/reversedns.log.
  2. Reads the hostname from /etc/hostname.
  3. Asks checkip.amazonaws.com for the server's public IPv4 address.
  4. Runs host <ip>, and takes the name after domain name pointer, without its trailing dot.
  5. Compares that name with the hostname, exactly. If they are equal, it prints one line. Otherwise it prints both names and the mismatch message.

Fixing a mismatch

The PTR record belongs to the owner of the IP address, so you set it outside the server:

  1. Choose the name that mail should come from, normally the server's hostname (for example server.example.com).
  2. In your hosting provider's control panel (or by asking their support), set the reverse DNS of the server's IP address to that name.
  3. Wait for the change to spread, then run /go/reversedns again.

If the hostname itself is wrong, change it with hostname instead.

What it does not check


See also

Command Description
hostname Change the server hostname and set up GoAdmio, mail, and SSL for it
checkimap Check the IMAP hostname, its DNS record, and the SSL certificate on port 993, repair the mail SSL setup when the certificate is missing, and alert the administrator about hostname and DNS problems
checkmail Test whether outbound mail port 25 works from this server, and whether the SMTP (465) and IMAP (993) SSL certificates are installed. This command also opens the local firewall.
troubleshoot Troubleshoot email problems in GoAdmio
checkdkim Check whether each domain's DKIM DNS record exists and matches the DKIM key on this server
resolver Change the DNS resolver in GoAdmio