How to Perform Reverse DNS Lookup

Everyone knows that DNS is used to translate hostnames to IP addresses, but do you know that DNS can also be used to retrieve the domain name when the IP address is known?

I am not a DNS guru, but I do know that the ping command in Windows can be used to resolve IP addresses to hostnames by using the -a option.

I had no clue how the reverse DNS query was performed by the ping command. To find out, I decided to analyse the DNS lookup query by using Wireshark, a network protocol analyzer. While trying to get the DNS name of the IP address of 8.8.4.4 (one of Google’s public DNS servers), I performed a packet capture.

wireshark reverse dns packet capture

After some reading up, I managed to find out how reverse DNS lookup or reverse IP lookup works.

  1. The IP address is first reversed and the string .in-addr.arpa is added to the end of the IP address. So if the IP address is 8.8.4.4, then the query becomes 4.4.8.8.in-addr.arpa
  2. The DNS query type is PTR
  3. The DNS query class is IN

Now we have the necessary info to perform reverse DNS lookup. Now, let’s look at ways to perform reverse DNS lookups.

The first way is by using nslookup, a DNS query tool. The nslookup command is available in UNIX, Linux and Windows.

Is it too complicated? Fret not! There is another simpler way to do it using nslookup! Here you go:

Another DNS lookup utility commonly found in UNIX and Linux is the host utility.

The final DNS lookup utility is called dig – a flexible tool for interrogating DNS name servers.

If you are just interested in the answer section of the dig command output, append the +noall and +answer options to the dig command. Alternatively, you can use the +short option.

ibrahim = { interested_in(unix, linux, android, open_source, reverse_engineering); coding(c, shell, php, python, java, javascript, nodejs, react); plays_on(xbox, ps4); linux_desktop_user(true); }