How do you know if reverse dns is setup correctly on your server

Solution 1:

Just some terminology adjustments here. Reverse DNS isn't setup on your server. Your server is assigned IP addresses and those IP addresses have reverse DNS entries. Those IPs are completely independent of your server.

Get the IP address of your server

$ ip addr show

now check to see if you can resolve it

$ host 1.2.3.4

where 1.2.3.4 is your IP e.g.

$ host 74.125.67.100
100.67.125.74.in-addr.arpa domain name pointer gw-in-f100.1e100.net.

This obviously uses your local nameservers and there is always the possibility that you have records cached if you've previously looked it up and it wasn't there. This is a good method to check whether your provider has setup the rDNS properly for you:

Reverse DNS works by reversing each of the octets of the IP address and using the in-addr.arpa domain. Using the IP I've used above (74.125.67.100) as an example, 74 is the first octet, 125 is the second octet etc.

So in reversing it we get 100.67.125.74 ... now add on in-addr.arpa to the end to get the PTR record for that IP

i.e.

100.67.125.74.in-addr.arpa ptr

dig is the canonical tool for debugging DNS, so to find out where the nameservers are for this class, you need to keep stripping off octets to find them.

e.g.

$ dig +short 67.125.74.in-addr.arpa
$ dig +short 125.74.in-addr.arpa
ns4.google.com.
ns1.google.com.
ns2.google.com.
ns3.google.com.

Right, we have a match. That means ns{1,2,3,4}.google.com handle the reverse records for all IPs 74.125.x.x

So, to query against their nameservers directly, we use:

$ dig +short 100.67.125.74.in-addr.arpa @ns4.google.com ptr
gw-in-f100.1e100.net.

Solution 2:

On windows (or other platforms with nslookup) do this

>nslookup      
>set q=ptr        
><YOUR IP ADDRESS>

This will return the reverse DNS (PTR) record for your IP address, if it exists.

For example:

>8.8.8.8
Server:     8.8.8.8
Address:    8.8.8.8#53

Non-authoritative answer:
8.8.8.8.in-addr.arpa    name = google-public-dns-a.google.com.