Linux下的ping6

昨天分别试用了一下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地址,就必须指定从哪个接口出去,否则系统不知道是哪条链路上的地址。

©️2020 CSDN 皮肤主题: 大白 设计师: CSDN官方博客 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值