昨天分別試用了一下Linux下和Windows下的IPv6 Ping,發現無法ping Link-local地址,百思不得其解,遂上網google一下,終於找到了原因。
Windows XP下的IPv6地址:
Ethernet adapter Test:
Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 192.168.39.137
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IP Address. . . . . . . . . . . . : fe80::21a:a5ff:fec1:1060%6
Default Gateway . . . . . . . . . : 192.168.39.1
fe80::20f:e6ff:fed4:33da%6
注意其中%6表示介面編號。
Linux下的IPv6地址:
eth0 Link encap:Ethernet HWaddr 00:1C:A0:C5:16:CD
inet addr:192.168.39.226 Bcast:192.168.39.255 Mask:255.255.255.0
inet6 addr: fe80::21c:a0ff:fec5:16cd/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:274560 errors:11 dropped:0 overruns:0 frame:11
TX packets:4651 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:25845320 (24.6 MiB) TX bytes:1234107 (1.1 MiB)
Interrupt:16
在Windows下ping Linux機器:
C:/>ping fe80::21c:a0ff:fec5:16cd
Destination net unreachable.
Destination net unreachable.
Destination net unreachable.
需要使用帶介面ID的地址:
C:/>ping fe80::21c:a0ff:fec5:16cd%6
Pinging fe80::21c:a0ff:fec5:16cd%6 with 32 bytes of data:
Reply from fe80::21c:a0ff:fec5:16cd%6: time<1ms
Reply from fe80::21c:a0ff:fec5:16cd%6: time<1ms
Reply from fe80::21c:a0ff:fec5:16cd%6: time<1ms
Reply from fe80::21c:a0ff:fec5:16cd%6: time<1ms
Ping statistics for fe80::21c:a0ff:fec5:16cd%6:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
Linux機器上:
[root@test ~]$ ping6 fe80::21a:a5ff:fec1:1060
connect: Invalid argument
網上一篇文章提到這個問題:
https://bugzilla.redhat.com/show_bug.cgi?id=136852
The point is that link-local adress can't be used in this way. You'd
better set a different global ipv6 adress to eth0 or specify device
used for ping - ping6 -I eth0 fe80:: ...
也就是必須帶介面名:
[heym@jupiter ~]$ ping6 -I eth0 fe80::21a:a5ff:fec1:1060
PING fe80::21a:a5ff:fec1:1060(fe80::21a:a5ff:fec1:1060) from fe80::21c:a0ff:fec5:16cd eth0: 56 data bytes
64 bytes from fe80::21a:a5ff:fec1:1060: icmp_seq=0 ttl=64 time=4.23 ms
64 bytes from fe80::21a:a5ff:fec1:1060: icmp_seq=1 ttl=64 time=0.366 ms
64 bytes from fe80::21a:a5ff:fec1:1060: icmp_seq=2 ttl=64 time=0.369 ms
分析:
由於Link-Local地址的形式都是: FE80::a:b:c:d 格式,不帶任何子網資訊等指示路由。因此如果有多個網卡的機器上就有多個Link-Local地址,就必須指定從哪個介面出去,否則系統不知道是哪條鏈路上的地址。