Linux下的ping6__Linux

來源:互聯網
上載者:User

昨天分別試用了一下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地址,就必須指定從哪個介面出去,否則系統不知道是哪條鏈路上的地址。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.