8

I know we can use dig -x to perform a reverse DNS query.

I have a textbook in front of me that says that both dig ptr and dig -x are valid syntax.

dig -x definitely works for me, but I'm not getting an answer with dig ptr:

~ $ dig ptr 216.239.34.10

; <<>> DiG 9.8.3-P1 <<>> ptr 216.239.34.10
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 41447
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;216.239.34.10.         IN  PTR

;; AUTHORITY SECTION:
.           10800   IN  SOA a.root-servers.net. nstld.verisign-grs.com. 2016113001 1800 900 604800 86400

;; Query time: 325 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Wed Nov 30 20:17:10 2016
;; MSG SIZE  rcvd: 106

~ $ dig -x 216.239.34.10

; <<>> DiG 9.8.3-P1 <<>> -x 216.239.34.10
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13022
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 4

;; QUESTION SECTION:
;10.34.239.216.in-addr.arpa.    IN  PTR

;; ANSWER SECTION:
10.34.239.216.in-addr.arpa. 86400 IN    PTR ns2.google.com.

;; AUTHORITY SECTION:
34.239.216.in-addr.arpa. 83894  IN  NS  ns1.google.com.
34.239.216.in-addr.arpa. 83894  IN  NS  ns4.google.com.
34.239.216.in-addr.arpa. 83894  IN  NS  ns2.google.com.
34.239.216.in-addr.arpa. 83894  IN  NS  ns3.google.com.

;; ADDITIONAL SECTION:
ns1.google.com.     327096  IN  A   216.239.32.10
ns2.google.com.     327096  IN  A   216.239.34.10
ns3.google.com.     327096  IN  A   216.239.36.10
ns4.google.com.     327096  IN  A   216.239.38.10

;; Query time: 17 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Wed Nov 30 20:17:18 2016
;; MSG SIZE  rcvd: 204

Is the textbook wrong or outdated?

  • 4
    dig ptr does work, if you use it as dig ptr 10.34.239.216.in-addr.arpa. – Vivek Thomas Nov 30 '16 at 20:37
26

dig -x is a form of "syntactic sugar" that was added to the program later.

Reverse DNS records, or PTR records, for IPv4 addresses are stored in the DNS in the reversed format that you see in the answers. In the past, when we wanted to see what the name was that associated with an IP address (example: 1.2.3.4), we would have to reverse the order of the octets, append the special suffix in-addr.arpa. and then tell dig to do a lookup of record type PTR instead of the default A record. So to look up the name associated with IP address 1.2.3.4 we would have to key in dig ptr 4.3.2.1.in-addr.arpa. Well, someone working on the dig code realized that they could save us a lot of trouble by adding a command-line switch to do the work in the program for us, thus dig -x 1.2.3.4 was born.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.