Monday, July 28, 2008

How to do reverse DNS lookup

Most people can better remember domain names, e.g.,, than their corresponding IP addresses, (In this example, is the home of the Free Software Foundation.) We delegate the responsibility to machines, aka, the DNS servers, to resolve the domain names for us.

Sometimes, we do need to manually lookup the IP address of a domain name. You may already be familiar with the nslookup command which is now deprecated. We use the dig command to make DNS queries.
 $ dig +noall +answer 67 IN CNAME 67 IN A

The IP address is displayed in the A record, and is

The +noall, +answer combination basically tells dig to only report the answer of the DNS query and skip the rest of the output.

You can also use the dig command with the -x option to do a reverse DNS lookup. A reverse DNS lookup means you want to look up the domain and host name of an IP address.

 $ dig +noall +answer -x 36000 IN CNAME 300 IN PTR

The PTR record is the one that contains the domain host name. The domain name is, as you expect,

Note that PTR records are not required for IP addresses. If a PTR record is not defined for an IP address, you cannot do a remote DNS lookup.


Anonymous said...

On most systems, this is more easily done using the host() command:

$ host has address mail is handled by 10 mail is handled by 20
$ host is an alias for domain name pointer

وظائف said...

thanks you ,very nice
but how can i dig for everything related to my domain,
it means anything affect my domain since it's rendered throw headers .. and till it cameback to browser
couse sometimes i have problems in my domain and ISP tells it server issue and server tell it's ISP issue :(

esvom. said...

thank you so much, very useful.

Anonymous said...

How to get PTR and SOA information together using one command in dig?

Anonymous said...

Or you can just use the nslookup command.

Elhanan Maayan said...

The problem is that they all give you the pretty name (with a dot suffix) if you try to place it in etc hosts file and use java InetAddress.getLocalhost you're in trouble