方法一:使用 link-local 地址进行点对点测试
步骤一:确认接口名和 link-local 地址
- 设备A:
neardi@LPA3588:~$ ip -6 addr show eth1 | grep inet6
inet6 fe80::44fe:3033:35d7:29b6/64 scope link noprefixroute
- 设备B:
neardi@LPA3588:~$ ip -6 addr show eth1 | grep inet6
inet6 fe80::d414:6d72:935f:ba94/64 scope link noprefixroute
步骤二:使用 ping6 指定接口进行测试
link-local 地址必须配合接口使用:
- 从 A 端 ping B 端:
ping6 fe80::d414:6d72:935f:ba94%eth1
- 从 B 端 ping A 端:
ping6 fe80::44fe:3033:35d7:29b6%eth1
ping6的结果:
#设备A
neardi@LPA3588:~$ ping6 fe80::d414:6d72:935f:ba94%eth1
PING fe80::d414:6d72:935f:ba94%eth1(fe80::d414:6d72:935f:ba94%eth1) 56 data bytes
64 bytes from fe80::d414:6d72:935f:ba94%eth1: icmp_seq=1 ttl=64 time=0.663 ms
64 bytes from fe80::d414:6d72:935f:ba94%eth1: icmp_seq=2 ttl=64 time=0.600 ms
#设备B
neardi@LPA3588:~$ ping6 fe80::44fe:3033:35d7:29b6%eth1
PING fe80::44fe:3033:35d7:29b6%eth1(fe80::44fe:3033:35d7:29b6%eth1) 56 data bytes
64 bytes from fe80::44fe:3033:35d7:29b6%eth1: icmp_seq=1 ttl=64 time=0.612 ms
64 bytes from fe80::44fe:3033:35d7:29b6%eth1: icmp_seq=2 ttl=64 time=0.574 ms
加 %eth1
的目的是:fe80:: 是局部地址不唯一,系统中可能有多个接口都能看到这个地址,所以系统需要指导通过哪个网卡发这的包。
也使用 iperf3 测试
设备A为server:
iperf3 -s -B fe80::44fe:3033:35d7:29b6%eth1
设备B为client:
iperf3 -c fe80::44fe:3033:35d7:29b6%eth1
iperf3的结果:
# 设备A
neardi@LPA3588:~$ iperf3 -s -B fe80::44fe:3033:35d7:29b6%eth1
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from fe80::d414:6d72:935f:ba94, port 60014
[ 5] local fe80::44fe:3033:35d7:29b6 port 5201 connected to fe80::d414:6d72:935f:ba94 port 60024
[ ID] Interval Transfer Bitrate
[ 5] 0.00-1.00 sec 10.7 MBytes 89.3 Mbits/sec
[ 5] 1.00-2.00 sec 11.1 MBytes 92.9 Mbits/sec
# 设备B
neardi@LPA3588:~$ iperf3 -c fe80::44fe:3033:35d7:29b6%eth1
Connecting to host fe80::44fe:3033:35d7:29b6%eth1, port 5201
[ 5] local fe80::d414:6d72:935f:ba94 port 60024 connected to fe80::44fe:3033:35d7:29b6 port 5201
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 11.8 MBytes 98.6 Mbits/sec 0 218 KBytes
[ 5] 1.00-2.00 sec 11.0 MBytes 92.5 Mbits/sec 0 227 KBytes
方法二:搭建 ULA 网络(私有 IPv6 网)
类似于 IPv4 的 192.168.x.x 段,IPv6 的 fd00::/8 是专为局域网设计的私有地址。
步骤一:分配地址
设备A分配一个地址:
sudo ip -6 addr add fd00::1/64 dev eth1
设备B分配一个地址:
sudo ip -6 addr add fd00::2/64 dev eth1
步骤二:使用 ping6 测试
设备A ping:
ping6 fd00::2
设备B ping:
ping6 fd00::1
ping6的结果:
# 设备A
neardi@LPA3588:~$ ping6 fd00::2
PING fd00::2(fd00::2) 56 data bytes
64 bytes from fd00::2: icmp_seq=1 ttl=64 time=0.592 ms
64 bytes from fd00::2: icmp_seq=2 ttl=64 time=0.599 ms
# 设备B
neardi@LPA3588:~$ ping6 fd00::1
PING fd00::1(fd00::1) 56 data bytes
64 bytes from fd00::1: icmp_seq=1 ttl=64 time=0.579 ms
64 bytes from fd00::1: icmp_seq=2 ttl=64 time=0.582 ms
也可以用 iperf3测试IPv6网络性能:
# 设备A 为 server 端(监听 IPv6)
iperf3 -s -V
# 设备B 为 client 端连接
iperf3 -c fd00::1 -V
iperf3的结果:
# 设备A
neardi@LPA3588:~$ iperf3 -s -V
iperf 3.7
Linux LPA3588 5.10.110 #1 SMP Wed Jan 8 20:51:35 CST 2025 aarch64
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Time: Mon, 21 Apr 2025 14:36:01 GMT
Accepted connection from fd00::2, port 52670
Cookie: qt6a5uvggur4g3hm4oesh6rr257jd2aaxjof
TCP MSS: 0 (default)
[ 5] local fd00::1 port 5201 connected to fd00::2 port 52674
Starting Test: protocol: TCP, 1 streams, 131072 byte blocks, omitting 0 seconds, 10 second test, tos 0
[ ID] Interval Transfer Bitrate
[ 5] 0.00-1.00 sec 10.7 MBytes 89.6 Mbits/sec
[ 5] 1.00-2.00 sec 11.1 MBytes 92.8 Mbits/sec
# 设备B
neardi@LPA3588:~$ iperf3 -c fd00::1 -V
iperf 3.9
Linux LPA3588 6.1.84 #1 SMP Wed Apr 9 11:21:26 CST 2025 aarch64
Control connection MSS 1428
Time: Mon, 21 Apr 2025 14:36:18 GMT
Connecting to host fd00::1, port 5201
Cookie: s42evps2vvsjslhep5pfyrpfky5cobz35sof
TCP MSS: 1428 (default)
[ 5] local fd00::2 port 56876 connected to fd00::1 port 5201
Starting Test: protocol: TCP, 1 streams, 131072 byte blocks, omitting 0 seconds, 10 second test, tos 0
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 11.7 MBytes 98.5 Mbits/sec 0 222 KBytes
[ 5] 1.00-2.00 sec 10.9 MBytes 91.5 Mbits/sec 0 237 KBytes