我在IPv6 7服务器中启用了CentOS,除了ping6之外,一切都正常工作:它显示请求之间出现3-5延迟(但RTT很好):
$ ping6 www.google.com
<...5 sec...>
PING www.google.com(2607:f8b0:4002:c09::69) 56 data bytes
<...5 sec...>
64 bytes from 2607:f8b0:4002:c09::69: icmp_seq=1 ttl=55 time=21.1 ms
<...5 sec...>
64 bytes from 2607:f8b0:4002:c09::69: icmp_seq=2 ttl=55 time=21.2 ms
<...5 sec...>
64 bytes from 2607:f8b0:4002:c09::69: icmp_seq=3 ttl=55 time=21.1 ms
<...5 sec...>
64 bytes from 2607:f8b0:4002:c09::69: icmp_seq=4 ttl=55 time=21.1 ms
<...5 sec...>
64 bytes from 2607:f8b0:4002:c09::69: icmp_seq=5 ttl=55 time=21.2 ms
<...5 sec...>
^C64 bytes from 2607:f8b0:4002:c09::69: icmp_seq=6 ttl=55 time=21.1 ms
--- www.google.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 25216ms
rtt min/avg/max/mdev = 21.119/21.183/21.251/0.043 ms然后,我通过strace (strace ping6 www.google.com)运行它,我可以看到它首先得到一个超时,试图平移IPv4地址,然后继续打开一个IPv6套接字并成功:
socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 4
connect(4, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("209.244.0.3")}, 16) = 0
gettimeofday({1415215545, 657352}, NULL) = 0
poll([{fd=4, events=POLLOUT}], 1, 0) = 1 ([{fd=4, revents=POLLOUT}])
sendto(4, "\2721\1\0\0\1\0\0\0\0\0\0\3www\6google\3com\0\0\34\0\1", 32, MSG_NOSIGNAL, NULL, 0) = 32
poll([{fd=4, events=POLLIN}], 1, 5000) = 0 (Timeout)
socket(PF_INET6, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 5
connect(5, {sa_family=AF_INET6, sin6_port=htons(53), inet_pton(AF_INET6, "2001:4860:4860::8844", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0
gettimeofday({1415215550, 663174}, NULL) = 0
poll([{fd=5, events=POLLOUT}], 1, 0) = 1 ([{fd=5, revents=POLLOUT}])
sendto(5, "\2721\1\0\0\1\0\0\0\0\0\0\3www\6google\3com\0\0\34\0\1", 32, MSG_NOSIGNAL, NULL, 0) = 32
poll([{fd=5, events=POLLIN}], 1, 3000) = 1 ([{fd=5, revents=POLLIN}])
ioctl(5, FIONREAD, [60]) = 0
recvfrom(5, "\2721\201\200\0\1\0\1\0\0\0\0\3www\6google\3com\0\0\34\0\1"..., 1024, 0, {sa_family=AF_INET6, sin6_port=htons(53), inet_pton(AF_INET6, "2001:4860:4860::8844", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, [28]) = 60ping6不应该专门查找AAAA记录并打开IPv6地址吗?为什么会发生这种情况?
发布于 2014-11-06 00:25:22
您的strace输出显示,ping6试图发出DNS请求以查找www.google.com的IP地址。
第一个DNS请求指向209.244.0.3,即解析1.level 3.net。此DNS请求在5秒后超时,此时它返回到第二个DNS服务器,2001:4860:4860::8844。此服务器几乎立即返回一个DNS响应。
我不知道这是如何进入到您系统的配置中的,尽管它可能是由您的服务提供商在为您提供机器时放在那里的。如果您不在他们的网络上,DNS服务器可能不会为您提供服务。
系统的DNS服务器将在/etc/resolv.conf中列出。在与服务提供商验证所使用的DNS服务器是否正确和功能之后,您可以在那里编辑和更正它们。
https://unix.stackexchange.com/questions/166205
复制相似问题