使用ping6命令Ping IPv6 IP地址

时间:2020-01-09 10:40:45  来源:igfitidea点击:

无法ping通IPv6地址。
我收到错误消息:

ping 2001:db8::1428:57ab ping: unknown host 2001:db8::1428:57ab

我的网络和基于Linux的操作系统已配置为IPv6 IP地址。
如何在Linux上ping IPv6地址?

常规ping命令仅适用于IPv4地址。使用ping6命令从主机或网关向网络主机发送ICMPv6 ECHO_REQUEST数据包。此命令使用ICMPv6协议强制性ICMP6_ECHO_REQUEST数据报来从主机或网关引出ICMP6_ECHO_REPLY。 ICMP6_ECHO_REQUEST数据报(ping)具有一个IPv6头,并且ICMPv6头的格式如RFC2463中所述。 ping6命令在Linux,BSD,Apple OS X和其他类似Unix的操作系统上可用。 MS-Widows用户可以使用" ping -6"命令,如此处所述。

ping到IPv6主机示例

执行命令,如下所示:

$ ping6 localhost
$ ping6 host.domain.com
$ ping6 IPv6-address
$ ping6 2001:4860:b002::68

最好的方法是ping ipv6.google.com等全球网站,执行:

$ ping6 ipv6.google.com

输出示例:

ping6 ipv6.google.com
PING ipv6.google.com(2001:4860:b002::68) 56 data bytes
64 bytes from 2001:4860:b002::68: icmp_seq=0 ttl=59 time=58.4 ms
64 bytes from 2001:4860:b002::68: icmp_seq=1 ttl=59 time=56.4 ms
64 bytes from 2001:4860:b002::68: icmp_seq=2 ttl=59 time=62.1 ms
64 bytes from 2001:4860:b002::68: icmp_seq=3 ttl=59 time=56.8 ms
64 bytes from 2001:4860:b002::68: icmp_seq=4 ttl=59 time=56.5 ms
64 bytes from 2001:4860:b002::68: icmp_seq=5 ttl=59 time=59.5 ms

--- ipv6.google.com ping statistics --
6 packets transmitted, 6 received, 0% packet loss, time 5002ms
rtt min/avg/max/mdev = 56.443/58.329/62.150/2.045 ms, pipe 2

通过IPv6 IP地址ping

首先,使用host命令找出www.theitroad.local的IPv6地址,执行:

$ host -t AAAA www.theitroad.local

输出示例:

www.theitroad.local has IPv6 address 2607:f0d0:1002:51::4

执行以下命令:

$ ping6 2607:f0d0:1002:51::4

输出示例:

PING 2607:f0d0:1002:51::4(2607:f0d0:1002:51::4) 56 data bytes
64 bytes from 2607:f0d0:1002:51::4: icmp_seq=1 ttl=64 time=0.056 ms
64 bytes from 2607:f0d0:1002:51::4: icmp_seq=2 ttl=64 time=0.027 ms
64 bytes from 2607:f0d0:1002:51::4: icmp_seq=3 ttl=64 time=0.021 ms
64 bytes from 2607:f0d0:1002:51::4: icmp_seq=4 ttl=64 time=0.023 ms
^C
--- 2607:f0d0:1002:51::4 ping statistics --
4 packets transmitted, 4 received, 0% packet loss, time 3831ms
rtt min/avg/max/mdev = 0.021/0.031/0.056/0.015 ms

再举一个例子:

$ host -t AAAA www.google.com
$ ping6 -c 4 2607:f8b0:4000:805::1010

如何确认已在基于Linux的系统上配置了IPv6或在其上正常工作?

执行以下命令(有关更多信息,请参见如何测试Linux操作系统的IPv6网络支持):

[ -f /proc/net/if_inet6 ] && echo 'IPv6 ready system!' || echo 'No IPv6 support found! Compile the kernel!!'

lsmod | grep -qw ipv6 && echo "IPv6 kernel driver loaded and configured." || echo "IPv6 not configured and/or driver loaded on the system."

关于MS-Windows XP/7/8 /服务器用户的说明

您可以使用ping命令测试IPv6连接。
在命令提示符下,执行:

ping -6 www.theitroad.local
ping -6 2607:f0d0:1002:51::4