domain-name-system – 为什么DNS查找不尊重/etc/nsswitch.conf和/etc/host.conf?

我有一个问题,即从DNS中查找主机名,即使它们存在于/ etc / hosts中.

我有以下配置:

/etc/host.conf档案:

order hosts,bind

/etc/nsswitch.conf中:

hosts:      files dns

在/etc/resolv.conf:

nameserver <nameserver one>
nameserver <nameserver two>

在主机上运行的应用程序会发出一些内部和外部API请求.

从tcpdump,我看到DNS查询到/ etc / hosts中列出的一些内部服务主机名.我正在使用的tcpdump命令是:

tcpdump -tqAlU -s0 port 53 and host <nameserver one>

在转储中,我看到如下请求:

IP 10.0.80.11.domain > app004-private.51308: UDP,length 102
E...I2..>...
.P.
.........I.1E...:...Q.. localhost............   ..@.a.root-servers.net..nstld.verisign-grs.com.w..
IP app004-private.33828 > 10.0.80.11.domain: UDP,length 39
E..Ca.@.@.B.
.2.
.P..$.5./..3e.......... localhost.site.com.....
IP 10.0.80.11.domain > app004-private.33828: UDP,length 96
E..|....>.T;
.P.
.2..5.$.hU.3e.......... localhost.site.com................-.ns10.dnshost.com...dns.8w.............u.....

请注意,localhost正在发送到DNS以及localhost.site.com. localhost的/ etc / hosts条目是:

127.0.0.1 localhost.localdomain localhost

IP 10.0.80.11.domain > app004-private.51664: UDP,length 93
E..yx...>.m.
.P.
.2..5...e.<N2...........api.site.com................-.ns10.dnshost...dns.5w.............u.....
IP app004-private.51664 > 10.0.80.11.domain: UDP,length 48
E..L`.@.@.C.
.2.
.P....5.8..n............api.site.com.site.com.....
IP 10.0.80.11.domain > app004-private.48878: UDP,length 76
E..h&e..>..w
.P.
.2..5...TQ..............11.80.0.10.in-addr.arpa.............Q............p.... .        :...Q.
IP 10.0.80.11.domain > app004-private.51664: UDP,length 105
E...VX..>..g
.P.
.2..5...qJ.n............api.site.com.site.com................-.ns10.dnshost.'.dns.Aw.............u.....

api.site.com位于/ etc / hosts中.运行getent查询api.site.com返回:

$getent hosts api.site.com
10.36.176.114   api001-private api001-private.site.com api001 api.site.com api

我很难过.似乎所有东西都正确配置(据我所知)首先使用/ etc / hosts然后使用DNS.有关为什么/etc/nsswitch.conf和/etc/host.conf没有被尊重的任何见解?

在系统上运行的主应用程序是http(apache 2.2.15和PHP 5.3.8 with curl 7.30.0).操作系统是运行内核2.6.18-238.9.1.el5和glibc 2.5-58.el5_6.3的Centos 5.6.

提前致谢!

解决方法

我们能够通过禁用ipv6来解决这个问题.我们通过将以下内容添加到/etc/modprobe.conf并重新启动来禁用ipv6.
alias net-pf-10 off
alias ipv6 off
options ipv6 disable=1

重新启动后,我们不再看到/ etc / hosts中列出的主机的DNS查找.

我不清楚为什么这解决了这个问题.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


html5中section的用法
span标签和p标签的区别
jsp文件和html文件的区别是什么
span标签和div的区别
html颜色代码表大全
span标签的作用是什么
dhtml的主要组成部分包括什么
html编辑器哪个软件好用
span标签属于什么样式标签
html文件乱码怎么办
html怎么读取json文件
html文件打开乱码怎么恢复原状
html怎么链接外部css
html文件怎么保存到本地
html怎么链接css文件
html和css怎么连接
html和css怎么关联
html文件怎么保存到一个站点
html文件怎么写
html出现乱码怎么解决