【问题标题】:virtualbox client machine: host name lookup failure in telnet while the same hostname lookup success in pingvirtualbox 客户端机器:telnet 中的主机名查找失败,而 ping 中相同的主机名查找成功
【发布时间】:2013-12-24 07:26:32
【问题描述】:

我设置了一个运行centos6.2 64bit的virtualbox客户端,主机是windows7 64bit,并在客户端设置了两个网卡,第一个是NAT模式,第二个是host-only模式,然后我陷入了运行客户端centos时出现以下问题:

当我 ping mirror.centos.org 时,似乎达到了这个名称:

PING mirror.centos.org (202.76.233.2) 56(84) bytes of data.
64 bytes from 202.76.233.2: icmp_seq=1 ttl=49 time=91.2 ms

当我 telnet 相同的主机名时,它失败了:

$ telnet mirror.centos.org 80
telnet: mirror.centos.org: Name or service not known
mirror.centos.org: Host name lookup failure

但是当我直接 telnet ip 时,它成功了:

$ telnet 202.76.233.2 80
Trying 202.76.233.2...
Connected to 202.76.233.2.
Escape character is '^]'.

我的问题是:当ping成功时,主机名似乎已经解析,为什么在telnet相同的主机名时再次查找失败? (实际上在yum等其他程序中也无法解析相同的主机名)

感谢您的帮助。

附加描述:

抱歉,问题描述有误,manully dns被路由器禁用了,看来centos又出现了这个问题。 我在运行“telnet www.centos.org 80”时使用tcpdump捕获dns包,日志列表在这里:

16:12:15.662796 IP 192.168.116.129.54451 > 192.168.116.2.domain: 19272+ A? www.centos.org. (32)
16:12:15.662914 IP 192.168.116.129.54451 > 192.168.116.2.domain: 33092+ AAAA? www.centos.org. (32)
16:12:15.665205 IP 192.168.116.2.domain > 192.168.116.129.54451: 19272 1/0/0 A 85.12.30.227 (48)
16:12:15.667042 IP 192.168.116.2.domain > 192.168.116.129.54451: 33092- 0/0/0 (43)
16:12:15.667121 IP 192.168.116.129.47706 > 192.168.116.2.domain: 19272+ A? www.centos.org. (32)
16:12:15.667226 IP 192.168.116.129.47706 > 192.168.116.2.domain: 33092+ AAAA? www.centos.org. (32)
16:12:15.667977 IP 192.168.116.2.domain > 192.168.116.129.47706: 19272 1/0/0 A 85.12.30.227 (48)
16:12:15.670181 IP 192.168.116.2.domain > 192.168.116.129.47706: 33092- 0/0/0 (43)
16:12:15.670291 IP 192.168.116.129.34270 > 192.168.116.2.domain: 61846+ A? www.centos.org.localdomain. (44)
16:12:15.670393 IP 192.168.116.129.34270 > 192.168.116.2.domain: 7936+ AAAA? www.centos.org.localdomain. (44)
16:12:15.671208 IP 192.168.116.2.domain > 192.168.116.129.34270: 61846 NXDomain*- 0/0/0 (44)
16:12:15.673649 IP 192.168.116.2.domain > 192.168.116.129.34270: 7936- 0/0/0 (55)
16:12:15.673726 IP 192.168.116.129.49484 > 192.168.116.2.domain: 61846+ A? www.centos.org.localdomain. (44)
16:12:15.673827 IP 192.168.116.129.49484 > 192.168.116.2.domain: 7936+ AAAA? www.centos.org.localdomain. (44)
16:12:15.674595 IP 192.168.116.2.domain > 192.168.116.129.49484: 61846 NXDomain*- 0/0/0 (44)
16:12:15.676653 IP 192.168.116.2.domain > 192.168.116.129.49484: 7936- 0/0/0 (55)

在第3行,dns服务器已经返回了查询的地址,但是“telnet”继续查询,后来它把一个尾巴放到了域(www.centos.org.localdomain),当然是一个错误的主机名字,为什么会这样?

【问题讨论】:

  • 建议:1) 安装Wireshark 并跟踪失败的查找。 2) 查看这些 Redhat 错误:Bug 504951Bug 508481Bug 442047
  • 问:为什么“ping”可以工作,但“telnet”在同一主机上失败? A:(由上面引用的 Redhat 错误建议):可能 telnet 客户端正在拉入不同的 NSS 库。附加建议:还可以考虑安装不同的“telnet”客户端。确保新客户端是 64 位的(没有 32 位依赖项)。
  • 感谢您的建议。我已经确定 telnet 是 x86-64,64 位客户端。
  • 很高兴您解决了问题:)
  • 我查了上面的Bug列表,centos没有nss-mdns这样的yum包,所以好像对centos没有影响。最后,我发现当我对客户端os(centos)的NAT模式网卡使用手动DNS时,即使ping也无法使用dns,同样的manully dns在我的主机上工作,很奇怪,并且接缝问题是在virtualbox中,我不熟悉它的网络。还是谢谢

标签: networking centos virtualbox


【解决方案1】:

日志文件可能会有所帮助,VirtualBox 中有三种名称解析模式,“NATing”UDP 请求、代理(当 DNS 请求被转发到主机的 DNS 服务器列表时)和主机解析(当 NAT 使用主机名解析 API 以回复 DNS 请求) - 所以日志可以指出是什么情况。如果您在此处的其他终端中打开至少 tcpdump "port domain" 的复制和粘贴输出。

【讨论】:

    猜你喜欢
    • 2021-11-14
    • 2020-03-08
    • 2019-11-09
    • 2011-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-07
    • 1970-01-01
    相关资源
    最近更新 更多