How to Do a Reverse DNS Lookup in Linux?

The Reverse DNS (also known as the rDNS) is used to find the hostname of the specified IP address. The Reverse DNS is used for troubleshooting networks and as an anti-spam. This is very helpful in recognizing the emails; if the rDNS fails to recognize them, they are moved to the junk/spam folder. Moreover, the rDNS looks up in the Pointer Record (PTR) to find the hostname associated with the specified IP address. 

This post will explain the possible ways to do a reverse DNS lookup in Linux. The content offered in this post is:

Method 1: Using the dig Command

The “dig” command is the DNS lookup utility that can also be used for the reverse DNS lookup. The general syntax of using the dig command for rDNS:

$ dig -x [IP Address]

The “x” option of the dig command is used to reverse DNS lookup. For example, we will look at google’s IP address using the command:

$ dig -x 8.8.8.8

It finds the hostname “dns.google” of the specified IP address “8.8.8.8”.

Method 2: Using the host command

Another method of using the rDNS Lookup in Linux is using the host command. The general syntax of using the host command to rDNS:

$ host ip_address

For example, we will look for the hostname associated with the IP address:

$ host 8.8.8.8

The hostname “dns.google” of the specified IP address “8.8.8.8” has been displayed above.

Method 3: Using the nslookup Command

The nslookup utility is used for managing the networks. It can also be used for rDNS by following the general syntax:

$ nslookup 8.8.8.8

It finds the hostname “dns.google” of the specified IP address “8.8.8.8”.

Apply a Reverse DNS on the localhost

Users can also apply a reverse DNS technique on the localhost by executing the following command:

$ nslookup localhost

It finds the specified IP address of the localhost of the machine.

Conclusion

To reverse DNS lookup in Linux, use the “dig”, “host”, and “nslookup” commands. It finds the hostname associated with the specified IP address. All these commands are beneficial for managing network configurations.

This blog has explained three different methods to perform reverse DNS in Linux.