Dam*_*der 5 domain-name-system http centos php5 curl
我有一个问题,即使主机名存在于 /etc/hosts 中,也会从 DNS 中查找主机名。
我有以下配置:
/etc/host.conf:
order hosts,bind
Run Code Online (Sandbox Code Playgroud)
/etc/nsswitch.conf:
hosts: files dns
Run Code Online (Sandbox Code Playgroud)
/etc/resolv.conf:
nameserver <nameserver one>
nameserver <nameserver two>
Run Code Online (Sandbox Code Playgroud)
主机上运行的应用程序会发出一些内部和外部 API 请求。
从 tcpdump 中,我看到了对 /etc/hosts.conf 中列出的一些内部服务主机名的 DNS 查询。我正在使用的 tcpdump 命令是:
tcpdump -tqAlU -s0 port 53 and host <nameserver one>
Run Code Online (Sandbox Code Playgroud)
在转储中,我看到如下请求:
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.....
Run Code Online (Sandbox Code Playgroud)
请注意,localhost 正在发送到 DNS 以及 localhost.site.com。本地主机的 /etc/hosts 条目是:
127.0.0.1 localhost.localdomain localhost
Run Code Online (Sandbox Code Playgroud)
和
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.....
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
我难住了。一切似乎都配置正确(据我所知)首先使用 /etc/hosts然后使用DNS。关于为什么 /etc/nsswitch.conf 和 /etc/host.conf 不被尊重的任何见解?
系统上运行的主要应用程序是 http(apache 2.2.15 和 PHP 5.3.8 with curl 7.30.0)。操作系统是 Centos 5.6,运行内核 2.6.18-238.9.1.el5 和 glibc 2.5-58.el5_6.3。
提前致谢!
我们可以通过禁用 ipv6 来解决此问题。我们通过将以下内容添加到 /etc/modprobe.conf 并重新启动来禁用 ipv6。
alias net-pf-10 off
alias ipv6 off
options ipv6 disable=1
Run Code Online (Sandbox Code Playgroud)
重新启动后,我们不再看到 /etc/hosts 中列出的主机的 DNS 查找。
我不清楚为什么这可以解决问题。
| 归档时间: |
|
| 查看次数: |
11674 次 |
| 最近记录: |