为什么 dig 无法从 LAN DNS 获得答案,但 ping 和 nslookup 却可以工作

为什么 dig 无法从 LAN DNS 获得答案,但 ping 和 nslookup 却可以工作

我设置了 LAN DNS,以便我可以通过非限定名称访问 LAN 主机。对于以下示例,域为“michigan”,主机为“acer”。

请注意,我可以 ping acer,但 dig acer 没有得到任何答复。只有当我为 dig 提供合格的名称时,dig 才会得到答复。

stephen@home:~$ ping -c1 acer 
64 bytes from 192.168.0.110 (192.168.0.110): icmp_seq=1 ttl=64 time=1.13 ms

stephen@home:~$ dig acer | grep ANSWER:
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

stephen@home:~$ dig acer.michigan | grep ANSWER:
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3

我的配置是否存在错误,或者这是 dig 的预期行为?

答案1

你自己找到了解决方案:

只有当我给予 dig 合格的名称时,dig 才会得到答案。

dig与其他工具不同,它不会自动将连接的 DNS 后缀附加到其查询中。这是预料之中的。

答案2

您的配置似乎有些混乱。如果您在同一个域中,则不需要输入域名。

man dig

NAME
       dig - DNS lookup utility

DESCRIPTION
       dig (domain information groper) is a flexible tool for interrogating
       DNS name servers. It performs DNS lookups and displays the answers that
       are returned from the name server(s) that were queried. Most DNS
       administrators use dig to troubleshoot DNS problems because of its
       flexibility, ease of use and clarity of output. Other lookup tools tend
       to have less functionality than dig.

       Unless it is told to query a specific name server, dig will try each of
       the servers listed in /etc/resolv.conf. If no usable server addresses
       are found, dig will send the query to the local host.

我搜索了dig手册页,但找不到这个词合格的其中的任何地方。

显示我的网络设置和示例:

terrance@terrance-ubuntu:~$ cat /etc/resolv.conf 
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 10.0.0.1
search local

terrance@terrance-ubuntu:~$ nslookup DD-WRT
Server:     10.0.0.1
Address:    10.0.0.1#53

Name:   DD-WRT.local
Address: 10.0.0.1

terrance@terrance-ubuntu:~$ dig DD-WRT

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

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;DD-WRT.                IN  A

;; ANSWER SECTION:
DD-WRT.         0   IN  A   10.0.0.1

;; Query time: 0 msec
;; SERVER: 10.0.0.1#53(10.0.0.1)
;; WHEN: Wed Apr 11 18:31:50 MDT 2018
;; MSG SIZE  rcvd: 51


terrance@terrance-ubuntu:~$ dig terrance-ubuntu

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

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;terrance-ubuntu.       IN  A

;; ANSWER SECTION:
terrance-ubuntu.    0   IN  A   10.0.0.100

;; Query time: 0 msec
;; SERVER: 10.0.0.1#53(10.0.0.1)
;; WHEN: Wed Apr 11 18:32:37 MDT 2018
;; MSG SIZE  rcvd: 60

我的结论是您的网络设置不正确。

相关内容