linux – 无法在CentOS中使用nslookup / dig解析主机名[已解决]

除了使用dig / nslookup之外,我无法解析主机名.在/ etc / hosts中声明主机工作正常. DNSmasq也没有绑定正在运行.以下是运行dig google.com时tcpdump端口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一起使用时,两个名称服务器都会产生良

路线结果-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甚至不允许登录. NSCD正在运行:nscd 28525 0.0 0.0 233652 2900? Ssl 20:10 0:00 /usr/sbin / nscd.

谢谢!

. . .编辑

我解决了这个问题/etc/nsswitch.conf有一行:

hosts:files赢得dns

我把它改为:

hosts:dns文件获胜

现在一切正常.奇怪的是,事情在上周工作正常.什么都没有改变,当然不是DNS.希望这有助于某人.

解决方法

您是否依赖主机名完成(或Windows世界中的“dns后缀附加”)来运行ping时获得完全限定的域名?如果是这样,您的/etc/resolv.conf缺少域和/或搜索选项.
nameserver 10.100.52.11
nameserver 10.100.52.13
domain corp.mxxxxxxs.com

这应该会自动将corp.mxxxxxxs.com附加到$HOST,以便您有一个正确解析的FQDN.

有关详细信息,请参阅manpage.

相关文章

linux常用进程通信方式包括管道(pipe)、有名管道(FIFO)、...
Linux性能观测工具按类别可分为系统级别和进程级别,系统级别...
本文详细介绍了curl命令基础和高级用法,包括跳过https的证书...
本文包含作者工作中常用到的一些命令,用于诊断网络、磁盘占满...
linux的平均负载表示运行态和就绪态及不可中断状态(正在io)的...
CPU上下文频繁切换会导致系统性能下降,切换分为进程切换、线...