当nslookup尝试解析地址时,为什么不查询我的/ etc / hosts文件?

梅兰

我有一对夫妇解决当地域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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

为什么对/ etc / hosts的更改立即生效?

/ etc / hosts的作用是什么?

Chrome为什么会忽略OS X上的/ etc / hosts?

/ etc / hosts文件中的通配符

为什么Chromium绕过/ etc / hosts和dnsmasq?

为什么没有必要更改/ etc / hosts

“ / etc / hosts”和“ / etc / hostname”的默认设置是什么?

跟踪对我的/ etc / hosts文件的编辑

/ etc / hosts的用途是什么?

为什么无法读取我的/ etc / hosts文件?

确定/ etc / hosts文件默认内容的规则是什么?

为什么hostname命令的输出与/ etc / hosts不同?

在Windows 10上编辑。\ etc \ hosts文件

/ etc / hosts是否可以包含我的主目录中的文件?

在创建脚本以更新/ etc / hosts文件中的主机名时遇到多个问题?

如何诊断/ etc / hosts文件无效

如何编辑/ etc / hosts文件

我的/ etc / hosts文件损坏了吗?

如何从类似于/ etc / hosts的文件中的IP地址获取主机名

Ubuntu / etc / hosts的地址为*。*。*。*格式

在文件/ etc / hosts中使用对文件的引用而不是IP

我想更改主机名-编辑/ etc / hosts文件是否足够?

重新启动后,Google Cloud Compute会不断更改我的/ etc / hosts文件

/ etc / hosts文件丢失–如何创建新的hosts文件?

为什么我在新命名空间中挂载 --bind --make-private /etc/hosts ,在旧命名空间中用 vim 修改这个文件也会影响新的 ns?

我的 /etc/hosts 没有效果

/etc/hosts 文件被永久实时 USB 覆盖

jinja for 循环盐文件.blockreplace for /etc/hosts

Android 中的 /etc/hosts 和 /system/etc/hosts 有什么区别?