nsswitch.conf与host.conf


10

假设该/etc/nsswitch.conf文件包含

hosts: files dns

/etc/host.conf文件有

order bind,hosts

那么系统将以哪种顺序使用/etc/hostsDNS查找来解析主机名?换句话说,两个配置文件中哪个优先?

Answers:


14

/etc/nsswitch.conf是最近几天用于域名解析的默认文件。我的/etc/host.conf文件顶部有以下一行:-

# The "order" line is only used by old versions of the C library.

nsswitch.confDebian盒子上的几乎所有东西都用于名称解析。因此,考虑到文件中的上述各行,默认名称解析顺序将是先检查/etc/hosts,然后使用在其中配置的名称服务器/etc/resolv.conf进行DNS查找。

最近(自Ubuntu 11.10起),/etc/resolv.conf默认情况下将其配置为使用localhost接口(127.0.0.1),在该接口中,守护程序dnsmasq在端口53上侦听DNS请求。反过来,这通常会按照局域网的DHCP服务器的配置进行DNS解析,但是可以在操作系统的网络配置GUI中手动覆盖它。

注意:您没有提到正在使用什么操作系统,并且以上内容来自Debian Ubuntu的个人经验。在不同版本的Linux上,默认设置可能有所不同

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.