`dig ptr`是执行反向DNS查询的有效方法吗?


19

我知道我们可以dig -x用来执行反向DNS查询。

我面前有一本教科书,上面提到这两个dig ptrdig -x都是有效的语法。

dig -x肯定对我有用,但是我没有得到答案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

教科书是错误的还是过时的?


7
dig ptr确实有效,如果您将其用作dig ptr 10.34.239.216.in-addr.arpa.
Vivek Thomas

Answers:


43

dig -x是“语法糖”的一种形式,后来被添加到程序中。

IPv4地址的反向DNS记录或PTR记录以您在答案中看到的反向格式存储在DNS中。过去,当我们想查看与IP地址相关联的名称(例如:1.2.3.4)时,我们必须颠倒八位字节的顺序,并附加特殊后缀in-addr.arpa。然后告诉dig查找记录类型PTR而不是默认的A记录。因此,要查找与IP地址1.2.3.4相关联的名称,我们必须键入dig ptr 4.3.2.1.in-addr.arpa.Well,而使用dig代码的人意识到,通过添加命令行开关来完成IP地址的工作,可以为我们节省很多麻烦。程序为我们dig -x 1.2.3.4而诞生。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.