不能parsing主机名,除非在CentOS中使用nslookup / dig

我无法parsing主机名,除了使用dig / nslookup。 在/etc/hosts声明主机工作正常。 DNSmasq或绑定正在运行。 以下是运行dig google.comtcpdump port 53的输出:

 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) 

结果在运行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) 

与主机名一起使用时,Ping不会返回任何数据包。 上述结果从给出命令后延迟~5秒。 我没有问题ping IP。

/etc/resolv.conf内容:

 nameserver 10.100.52.11 nameserver 10.100.52.13 

与dig一起使用时,这两个名称服务器都会给出好的结果

route -n结果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 

/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 

如果UseDNS设置为yes,SSHD甚至不允许login。 NSCD正在运行: nscd 28525 0.0 0.0 233652 2900 ? Ssl 20:10 0:00 /usr/sbin/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。 希望这有助于某人。

您是否依赖主机名完成(或Windows世界中的“dns后缀追加”)以在运行ping时获取完全限定的域名? 如果是这样,你的/etc/resolv.conf缺lessdomain和/或search选项。

 nameserver 10.100.52.11 nameserver 10.100.52.13 domain corp.mxxxxxxs.com 

这应该会自动将corp.mxxxxxxs.com附加到$ HOST,以便您拥有可正确parsing的FQDN。

有关更多详细信息,请参见手册页 。