How to perform a rDNS lookup

rDNS (Reverse DNS) is important for identify an IP address. Some internet service, for instance, sending email from an IP, needs rDNS to be setup correctly.

Here I tell how to perform a rDNS lookup from Linux. There are two simple ways.

The first way, using dig command. The full path is “dig -x IP”, as below:

 $ dig -x 23.95.246.240


 ; <<>> DiG 9.10.3-P4-Ubuntu <<>> -x 23.95.246.240
 ;; global options: +cmd
 ;; Got answer:
 ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11872
 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
 

 ;; OPT PSEUDOSECTION:
 ; EDNS: version: 0, flags:; udp: 512
 ;; QUESTION SECTION:
 ;240.246.95.23.in-addr.arpa. IN PTR
 

 ;; ANSWER SECTION:
 240.246.95.23.in-addr.arpa. 3599 IN PTR 23-95-246-240-host.colocrossing.com.
 

 ;; Query time: 178 msec
 ;; SERVER: 8.8.8.8#53(8.8.8.8)
 ;; WHEN: Tue Feb 23 10:31:28 HKT 2021
 ;; MSG SIZE  rcvd: 104 

In the “ANSWER SECTION”, you will see the PTR record type, the value following that is IP’s rDNS.

The second way, using curl command to query localhost’s rDNS. The full path is “curl -sL hostname.cloudcache.net”, as below:

 $ curl -sL hostname.cloudcache.net
 Your IP: 23.95.246.240, Hostname: 23-95-246-240-host.colocrossing.com. 

As you see, the “hostname:” part is rDNS value for your host’s IP.