I need to check a PTR record to make sure that a script I have is sending emails which will actually be received by my users and not be incorrectly marked as spam.
I understand that the ISP which owns the IP range has to set up the PTR record, but how do I check if it is already set up?
If you have Unix or Linux, you can do this by typing this on a command prompt:
You'll get an answer with your authority of aa.zz.yy.xx.in-addr.arpa and server resolving to this address.
In Windows you can do
nslookup xx.yy.zz.aa
.You can also check online at www.intodns.com and input your domain... It will error on the results checking for a reverse zone lookup.
xx.yy.zz.aa = The IP address you're trying to resolve
Update:
Zoredache makes a good point. Here are the commands for testing/resolving to external/outside DNS servers:
Dig (testing reverse DNS on Google's DNS server of 8.8.8.8):
Host and Nslookup (testing reverse dns on Google's DNS server of 8.8.8.8)
I know this has been marked as answered but I want to provide a more comprehensive answer. For my examples I will be using:
The first thing to note is
dig
is a multiplatform command, you can get it for Windows on the ISC BIND website listed under BIND, then select your Windows platform (32 or 64 bit). It has many other tools including its own nslookup binary. I don't use that nslookup.exe version, instead I use the default one that comes with Windows (C:\Windows\System32\nslookup.exe). However if you want to usedig
you may want to edit your local PATH environment variable, or move thedig
tool to your C:\Windows\System32 folder.Command 1)
dig PTR 206.3.217.172.in-addr.arpa
- Traditionally this is how a user would perform a reverse DNS lookup. They would manually transpose the IP address:172.217.3.206
to206.3.217.172
(notice the order of each of the four octets) and addin-addr.arpa
to the end of the string. Here is the output:Command 2)
dig -x 172.217.3.206
- This version of the command is a lot simpler, as described in thedig -h
, the-x
flag is a "shortcut for reverse lookups". The output is identical to the output shown above in the previous command.Command 3)
dig -x 151.101.1.69
- This example is showing what it looks like when a PTR record is not found, using the serverfault.com example. As you can see, the answer does not list a PTR, and can only find the SOA record of151.in-addr.arpa
:Command 4)
nslookup 172.217.3.174
- This is the command suggested by user l0c0b0x in the primary answer on this thread. While it is true that there is a result, it is not clear if this is a PTR record or some other type of record. I think it does by default return a PTR if it is given an IP, but I still want to be sure. It also omits other records if there are multiple PTRs:Command 5)
nslookup -debug 172.217.3.174
- Use this command instead to see the full list, including the record type and the full list of results. The-debug
flag persists, to turn it off you must use-nodebug
:Command 6)
nslookup -type=PTR 172.217.3.174
- This version of the command specifies PTR records with the-type
flag. It is different than the version without the-type
flag in two ways. The first is it lists all PTR answers. The second is that it includes the information "Non-authoritative answer" which the other command neglects to include. If you carefully look above at the debug output, theauthority records
state 0, so both of these commands should state "Non-authoritative answer".Command 7)
nslookup -debug -d2 -type=PTR 151.101.1.69
- Here is how you would get as much detail as possible about the full reverse lookup request. Reminder: To turn it off use-nodebug
and-nod2
. This example is purposely failing on the serverfault.com example:Command 8)
nslookup 174.3.217.172.in-addr.arpa
- You may be wondering if you can use the traditional reverse DNS lookup method withnslookup
as we did in Command 1 withdig
. You can. Notice the same nslookup failings as I listed above (Command 6) between this command and the one with the-type=PTR
flag set below (Command 9):Command 9)
nslookup -type=PTR 174.3.217.172.in-addr.arpa
- As you may expect, it looks identical to Command 6.It is the same as doing any kind of DNS lookup.
From a windows command prompt:
nslookup.exe <ip address>
From a linux command line:
host <ip address>
Note: It is probably best to run these commands from a computer outside of your network, so that you are accessing a public DNS server. Alternatively, both nslookup and host offer ways to specify the DNS server to use.
Intro:
(2) examples, one for IPv4 and the other for IPv6.
The IPv6 PTR lookup procedure took me ages to find an answer to...
IPv4:
We'll use Google's IP for the IPv4 example:
Returns the reverse mapping:
IPv6:
STEP 1: Obtain the IPv6 address of the host (usually a mailserver):
This returns the IPv6 address we need for the PTR lookup in the next step:
STEP 2:Now supply the IPv6 address to the
host
command:Returns the IPv6 PTR record:
NOTE: the IPv6 address has been anonymized.
Since Hurricane Electric gave me the FREE IPv6 block, I set the reverse IPv6 DNS directly in their DNS control panel for mailserver.
Reverse IPv6 Generator:
Obviously, the above IPv6 PTR record is a bit crazy and being lazy, I just used a reverse IPv6 Generator to create it for my mailserver. There are others, but I used the following to derive the correct value for the reverse IPv6:
https://www.whatsmydns.net/reverse-dns-generator
For the IP V4 example on
1.1.1.1
you can try these on Linux to get the name from the IP.Or
Or