tsz*_*tsz 6 networking domain-name-system linux linux-networking
我无法解析主机名,除非使用 dig/nslookup。声明主机/etc/hosts工作正常。DNSmasq 或 bind 正在运行。以下是tcpdump port 53运行时的输出dig google.com:
21:02:49.269083 IP txxxxxx1.corp.mxxxxxxs.com.39872 > dxxxxxx3.corp.mxxxxxs.com.domain: 7362+ A? google.com. (28)
21:02:49.269614 IP dxxxxxx3.corp.mxxxxxxs.com.domain > txxxxxx1.corp.mxxxxxxs.com.39872: 7362 5/0/0 A ord08s07-in-f19.1e100.net,[|domain]
21:02:49.270506 IP txxxxxx1.corp.mxxxxxxs.com.33316 > dxxxxxx3.corp.mxxxxxxs.com.domain: 30910+ PTR? 83.225.125.74.in-addr.arpa. (44)
21:02:49.303321 IP dxxxxxx3.corp.mxxxxxxs.com.domain > txxxxxx1.corp.mxxxxxxs.com.33316: 30910*- 1/0/0 (83)
Run Code Online (Sandbox Code Playgroud)
运行时的结果ping google.com:
21:03:05.027197 IP txxxxxx1.corp.mxxxxxxs.com.59151 > dxxxxxx3.corp.mxxxxxxs.com.domain: 56092+ A? google.com. (28)
21:03:05.029069 IP dxxxxxx3.corp.mxxxxxxs.com.domain > txxxxxx1.corp.mxxxxxxs.com.59151: 56092 5/0/0 A ord08s07-in-f18.1e100.net,[|domain]
21:03:05.029309 IP txxxxxx1.corp.mxxxxxxs.com.58238 > dxxxxxx3.corp.mxxxxxxs.com.domain: 10345+ PTR? 82.225.125.74.in-addr.arpa. (44)
21:03:05.065058 IP dxxxxxx3.corp.mxxxxxxs.com.domain > txxxxxx1.corp.mxxxxxxs.com.58238: 10345*- 1/0/0 (83)
Run Code Online (Sandbox Code Playgroud)
与主机名一起使用时,Ping 不会返回任何数据包。上面的结果从给出命令后延迟了大约 5 秒。ping IP 没有问题。
内容/etc/resolv.conf:
nameserver 10.100.52.11
nameserver 10.100.52.13
Run Code Online (Sandbox Code Playgroud)
当与 dig 一起使用时,这两个名称服务器都能提供良好的结果。
结果route -n:
Destination Gateway Genmask Flags Metric Ref Use Iface
10.xxx.131.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 10.xxx.131.1 0.0.0.0 UG 0 0 0 eth0
Run Code Online (Sandbox Code Playgroud)
内容/etc/hosts:
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
10.xxx.131.xxx txxxxxx1.corp.mxxxxxxs.com ast01
10.xxx.32.xxx mail.mxxxxxxs.com
Run Code Online (Sandbox Code Playgroud)
如果UseDNS设置为 yes,SSHD 甚至不允许登录。NSCD 正在运行:nscd 28525 0.0 0.0 233652 2900 ? Ssl 20:10 0:00 /usr/sbin/nscd。
谢谢!
. . . 编辑
我解决了这个问题。 /etc/nsswitch.conf有这条线:
hosts: files wins dns
我把它改成这样:
hosts: dns files wins
现在一切正常。奇怪的是,直到上周,一切都运转良好。没有任何改变,当然没有 DNS。希望这可以帮助某人。
小智 1
当您运行 ping 时,您是否依赖主机名补全(或 Windows 世界中的“dns 后缀附加”)来获取完全合格的域名?如果是这样,则您/etc/resolv.conf缺少domain和/或search选项。
nameserver 10.100.52.11
nameserver 10.100.52.13
domain corp.mxxxxxxs.com
Run Code Online (Sandbox Code Playgroud)
这应该会自动将 corp.mxxxxxxs.com 附加到 $HOST,以便您拥有可以正确解析的 FQDN。
有关更多详细信息,请参阅联机帮助页。