![无法使用链路本地地址 ping 通 ipv6 设备](https://linux22.com/image/153937/%E6%97%A0%E6%B3%95%E4%BD%BF%E7%94%A8%E9%93%BE%E8%B7%AF%E6%9C%AC%E5%9C%B0%E5%9C%B0%E5%9D%80%20ping%20%E9%80%9A%20ipv6%20%E8%AE%BE%E5%A4%87.png)
我有一个带有链接本地地址的 IPv6 设备fe80::204:9fff:fe04:7fb5
(ifconfig 的输出如下)。我的机器有一个地址fe80::d939:2d31:6fe2:c203
。我尝试以两种方式进行 ping 操作(从机器到设备以及从机器到设备),但我得到的只是Destination unreachable: Address unreachable
(下面提供了确切的输出)。
我花了很长时间查看不同的论坛试图找出问题所在,但无法找到答案。我还应该指出,我对 IPv6 不是很熟悉。我还阅读了很多有关该主题的文章,只是不确定设置是否存在问题。
ifconfig
设备的输出:
eth2 Link encap:Ethernet HWaddr 00:04:9f:04:7f:b5
inet6 addr: fe80::204:9fff:fe04:7fb5/64 Scope:Link
inet6 addr: 2001:c001:5afe:b1::e20:d001/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:23 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:1898 (1.8 KiB)
ifconfig
我的机器的输出:
enp0s31f6: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::d939:2d31:6fe2:c203 prefixlen 64 scopeid 0x20<link>
ether 54:e1:ad:92:26:52 txqueuelen 1000 (Ethernet)
RX packets 545 bytes 62724 (61.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4000 bytes 460567 (449.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 16 memory 0xec200000-ec220000
从机器到设备的 ping 输出
ping6 -I enp0s31f6 fe80::204:9fff:fe04:7fb5
ping6: Warning: source address might be selected on device other than enp0s31f6.
PING fe80::204:9fff:fe04:7fb5(fe80::204:9fff:fe04:7fb5) from :: enp0s31f6: 56 data bytes
From fe80::d939:2d31:6fe2:c203%enp0s31f6: icmp_seq=1 Destination unreachable: Address unreachable
From fe80::d939:2d31:6fe2:c203%enp0s31f6: icmp_seq=2 Destination unreachable: Address unreachable
From fe80::d939:2d31:6fe2:c203%enp0s31f6: icmp_seq=3 Destination unreachable: Address unreachable
从设备到机器的 ping 输出
ping6 -I eth2 fe80::d939:2d31:6fe2:c203
PING fe80::d939:2d31:6fe2:c203(fe80::d939:2d31:6fe2:c203) from fe80::204:9fff:fe04:7fb5%eth2 eth2: 56 dat
a bytes
From fe80::204:9fff:fe04:7fb5%eth2 icmp_seq=1 Destination unreachable: Address unreachable
From fe80::204:9fff:fe04:7fb5%eth2 icmp_seq=2 Destination unreachable: Address unreachable
From fe80::204:9fff:fe04:7fb5%eth2 icmp_seq=3 Destination unreachable: Address unreachable
答案1
[您应该检查您的防火墙/ip6tables 规则。这应该可行——当然,假设两个设备直接连接]
当 ping 链接本地 ipv6 地址时,您还可以通过%
- 语法包含链接规范:
ping6 fe80::dfef:2fb9:b91c:89a0%l_br0
PING fe80::dfef:2fb9:b91c:89a0%l_br0(fe80::dfef:2fb9:b91c:89a0%l_br0) 56 data bytes
64 bytes from fe80::dfef:2fb9:b91c:89a0%l_br0: icmp_seq=1 ttl=64 time=0.615 ms
...
(注意...%l_br0
;l_br0
是我的桥的名字;您必须将...%enp0s31f6
或...%eth2
与您的地址一起使用)。
当使用netcat
等时,您必须使用%
语法,因为它们无法像ping6
via那样指定接口-I
。例如,在机器上监听:
nc -l fe80::dfef:2fb9:b91c:89a0%em0 8888
并从另一个连接:
nc fe80::dfef:2fb9:b91c:89a0%l_br0 8888
(第一台具有该em0
接口的机器正在运行 OpenBSD;第二台具有该l_br0
接口的机器正在运行 Linux)。