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

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

;         IN  PTR

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

;; Query time: 325 msec
;; WHEN: Wed Nov 30 20:17:10 2016
;; MSG SIZE  rcvd: 106

~ $ dig -x

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

;    IN  PTR

;; ANSWER SECTION: 86400 IN    PTR ns2.google.com.

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.

ns1.google.com.     327096  IN  A
ns2.google.com.     327096  IN  A
ns3.google.com.     327096  IN  A
ns4.google.com.     327096  IN  A

;; Query time: 17 msec
;; 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 – Vivek Thomas Nov 30 '16 at 20:37

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:, 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 we would have to key in dig ptr 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 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.