我有一对夫妇解决当地域127.0.0.1
在我的/etc/hosts
文件。一段时间没事,但现在我跑步了:
nslookup test.local
结果是:
Server: 192.168.1.3
Address: 192.168.1.3#53
** server can't find test.local: NXDOMAIN
这192.168.1.3
是我们的网络DNS,它不应该知道我的本地域test.local
。经过几次搜索,我发现该/etc/nsswitch.conf
文件包含有关要查询的DNS源优先级的信息。但是那里没有问题!这是我的:
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
passwd: compat
group: compat
shadow: compat
hosts: files mdns4_minimal [NOTFOUND=return] dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
有人知道为什么我的hosts
文件未包含在DNS查找中吗?
nslookup
仅执行正确的DNS解析,这与您其他应用程序使用的名称服务交换子系统有很大不同;也就是说nslookup
忽略/etc/hosts
和mDNS。
要测试类似的本地分辨率,请使用使用NSS的工具。ping <hostname>
例如。这是一个基于/etc/hosts
我的网络条目的简单演示。
$ nslookup bert
Server: 8.8.8.8
Address: 8.8.8.8#53
** server can't find bert: NXDOMAIN
$ ping bert
PING bert (10.10.0.4) 56(84) bytes of data.
64 bytes from bert (10.10.0.4): icmp_seq=1 ttl=64 time=0.352 ms
64 bytes from bert (10.10.0.4): icmp_seq=2 ttl=64 time=0.407 ms
请注意,有些DNS服务器和代理可以将/etc/hosts
文件包含在内。在这些情况下,nslookup
可能会从本地来源返回结果。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句