Debian 无法解析主机名

Debian 无法解析主机名

我在解析 VMWare 上运行的 Debian 上的主机名时遇到问题。

它突然停止工作了。卸载 percona 服务器并删除 /etc/mysql.conf 之后的某个地方最初,当来宾运行时主机处于睡眠状态时,它认为这是网络问题,这是 VMWare 的一个已知问题。但不可能。

Debian 7.4,已安装 VMWare 工具

/etc/resolv.conf

# Generated by NetworkManager
nameserver 8.8.8.8
nameserver 8.8.4.4

ping、dig 和 nslookup 输出

ivar@debian:~$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_req=1 ttl=47 time=40.0 ms
64 bytes from 8.8.8.8: icmp_req=2 ttl=47 time=39.7 ms
^C
--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 39.747/39.874/40.001/0.127 ms
ivar@debian:~$ dig google.com

; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18895
;; flags: qr rd ra; QUERY: 1, ANSWER: 11, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;google.com.            IN  A

;; ANSWER SECTION:
google.com.     299 IN  A   173.194.113.100
google.com.     299 IN  A   173.194.113.99
google.com.     299 IN  A   173.194.113.96
google.com.     299 IN  A   173.194.113.103
google.com.     299 IN  A   173.194.113.110
google.com.     299 IN  A   173.194.113.102
google.com.     299 IN  A   173.194.113.98
google.com.     299 IN  A   173.194.113.105
google.com.     299 IN  A   173.194.113.97
google.com.     299 IN  A   173.194.113.101
google.com.     299 IN  A   173.194.113.104

;; Query time: 43 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Sat Mar 29 18:46:07 2014
;; MSG SIZE  rcvd: 204

ivar@debian:~$ nslookup google.com
Server:     8.8.8.8
Address:    8.8.8.8#53

Non-authoritative answer:
Name:   google.com
Address: 173.194.113.97
Name:   google.com
Address: 173.194.113.104
Name:   google.com
Address: 173.194.113.101
Name:   google.com
Address: 173.194.113.99
Name:   google.com
Address: 173.194.113.100
Name:   google.com
Address: 173.194.113.96
Name:   google.com
Address: 173.194.113.102
Name:   google.com
Address: 173.194.113.103
Name:   google.com
Address: 173.194.113.110
Name:   google.com
Address: 173.194.113.105
Name:   google.com
Address: 173.194.113.98

ivar@debian:~$ ping google.com
ping: unknown host google.com

有什么想法如何解决这个问题吗?

/etc/nsswitch.conf

# /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 wins [NOTFOUND=return] dns mdns4
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

答案1

对于您当前的nsswitch.confdns,只有在请求wins失败时才会请求。以下是nsswitch.conf我系统上的联机帮助页的相关摘录:

notfound
查找成功,但未找到请求的条目。此条件的默认操作是“继续”。

return
立即返回结果。不要调用任何进一步的查找函数。

在您的示例中,您成功查询了 WINS,但没有检索到 的结果google.com。要解决此问题,您可以删除[NOTFOUND=return]或重新排序为主机查找而查询的服务。这是一个修复示例:

hosts:          files mdns4_minimal dns wins [NOTFOUND=return] mdns4

相关内容