DNS 问题?我无法 ping FQDN,但我可以 ping 别名 (CNAME)

DNS 问题?我无法 ping FQDN,但我可以 ping 别名 (CNAME)

我遇到了奇怪的 DNS 问题,想知道是否有人有什么想法:

# ping -c1 test.XXX.local
ping: unknown host test.XXX.local
# ping -c1 test
PING test.XXX.local (10.52.223.41) 56(84) bytes of data.
64 bytes from test.XXX.local (10.52.223.41): icmp_seq=1 ttl=63 time=0.307 ms

--- test.XXX.local ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.307/0.307/0.307/0.000 ms
#

我的/etc/resolv.conf

$ cat /etc/resolv.conf 
search XXX.local
nameserver 10.52.223.41
nameserver 10.52.223.42
$ 

我的/etc/hosts

# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
# 

挖掘输出:

# dig test.XXX.local @10.52.223.41

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> test.XXX.local @10.52.223.41
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25966
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 1

;; QUESTION SECTION:
;test.XXX.local.        IN  A

;; ANSWER SECTION:
test.XXX.local. 86400   IN  A   10.52.223.41

;; AUTHORITY SECTION:
XXX.local.      86400   IN  NS  ns01.XXX.local.
XXX.local.      86400   IN  NS  ns02.XXX.local.

;; ADDITIONAL SECTION:
ns02.XXX.local. 1200    IN  A   10.52.223.42

;; Query time: 0 msec
;; SERVER: 10.52.223.41#53(10.52.223.41)
;; WHEN: Tue Feb 18 13:14:16 2014
;; MSG SIZE  rcvd: 105

# 

/etc/nsswitch.conf

# cat /etc/nsswitch.conf
#
# /etc/nsswitch.conf
#
# An example Name Service Switch config file. This file should be
# sorted with the most-used services at the beginning.
#
# The entry '[NOTFOUND=return]' means that the search for an
# entry should stop if the search in the previous entry turned
# up nothing. Note that if the search failed due to some other reason
# (like no NIS server responding) then the search continues with the
# next entry.
#
# Valid entries include:
#
#   nisplus         Use NIS+ (NIS version 3)
#   nis         Use NIS (NIS version 2), also called YP
#   dns         Use DNS (Domain Name Service)
#   files           Use the local files
#   db          Use the local database (.db) files
#   compat          Use NIS on compat mode
#   hesiod          Use Hesiod for user lookups
#   [NOTFOUND=return]   Stop searching if not found so far
#

# To use db, put the "db" in front of "files" for entries you want to be
# looked up first in the databases
#
# Example:
#passwd:    db files nisplus nis
#shadow:    db files nisplus nis
#group:     db files nisplus nis

passwd:     files
shadow:     files
group:      files

#hosts:     db files nisplus nis dns
hosts:      files mdns4_minimal [NOTFOUND=return] dns

# Example - obey only what nisplus tells us...
#services:   nisplus [NOTFOUND=return] files
#networks:   nisplus [NOTFOUND=return] files
#protocols:  nisplus [NOTFOUND=return] files
#rpc:        nisplus [NOTFOUND=return] files
#ethers:     nisplus [NOTFOUND=return] files
#netmasks:   nisplus [NOTFOUND=return] files     

bootparams: nisplus [NOTFOUND=return] files

ethers:     files
netmasks:   files
networks:   files
protocols:  files
rpc:        files
services:   files

netgroup:   nisplus

publickey:  nisplus

automount:  files nisplus
aliases:    files nisplus

# 

答案1

如果您有mdns4_minimal [NOTFOUND=return]nsswitch.conf这肯定是因为您Avahi的系统上正在运行守护进程。

Avahi.local区域使用多播 DNS,这使其与仅支持区域单播 DNS 的 DNS 不兼容.local。(例如,Microsoft 的 DNS 仅支持.local区域的单播 DNS)。

在这样的网络设置中(DNS仅支持.local区域的单播),Avahi建议不要使用Avahi

但是,他们提供了一些解决方法:

删除mdns4_minimal [NOTFOUND=return]nsswitch.conf最终得到如下内容:

hosts: files dns mdns4

avahi-daemon.conf但是他们的主要建议是像这样设置以避免.local区域的多播 DNS:

domain-name=.alocal

要解决您的问题,请执行以下操作:

  • 关闭Avahi守护进程

或者

  • nsswitch.conf根据建议进行设置:

hosts: files dns mdns4

或者

  • avahi-daemon.conf根据建议进行设置:

domain-name=.alocal


进一步阅读:

答案2

感谢@guntbert

# service avahi-daemon stop
Shutting down Avahi daemon:                                [  OK  ]
# ping test.XXX.local
PING test.XXX.local (10.52.223.42) 56(84) bytes of data.
64 bytes from test.XXX.local (10.52.223.42): icmp_seq=1 ttl=63 time=1.15 ms
^C
--- test.XXX.local ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 625ms
rtt min/avg/max/mdev = 1.152/1.152/1.152/0.000 ms
# chkconfig avahi-daemon off
# 

真的希望了解为什么?尽管...

答案3

修改 nsswitch.conf。将以下行

hosts: files mdns4_minimal [NOTFOUND=return] dns

hosts: files dns

mdns4_minimal [NOTFOUND=return] 影响 .local 域,不允许达到“dns”级别。因此我认为进行上述更改后,解析应该可以正常工作。

相关内容