测试
网络拓扑
开发板(RK3399) <----> 交换机 <----> 我的电脑(虚拟机)
配置指令
设置IP
# ip -6 addr add 1001:2001:2001:2001::159/64 dev eth0
# ip -6 addr del 1001:2001:2001:2001::159/64 dev eth0# ifconfig eth0 2001:2001:2001:2001::159/64
# ifconfig eth0 del 2001:2001:2001:2001::159/64IPV6的地址可以设置多个:
[root@rk3399:/]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 9A:0B:9D:ED:7F:96 inet addr:172.16.0.71 Bcast:172.16.255.255 Mask:255.255.0.0inet6 addr: 1001:2001:2001:2001::160/64 Scope:Globalinet6 addr: 1001:2001:2001:2001::159/64 Scope:Globalinet6 addr: 2001:2001:2001:2001::159/64 Scope:Globalinet6 addr: fe80::eb9d:77:e8d4:ed6f/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:2835 errors:0 dropped:23 overruns:0 frame:0TX packets:98 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000 RX bytes:332403 (324.6 KiB) TX bytes:15446 (15.0 KiB)Interrupt:24
查看路由
# ip -6 route show
fe80::/64 dev dummy0 metric 256
fe80::/64 dev wlan0 metric 256
fe80::/64 dev eth0 metric 256
ff00::/8 dev dummy0 metric 256
ff00::/8 dev eth0 metric 256
ff00::/8 dev wlan0 metric 256
unreachable default dev lo metric -1 error -101# route -A inet6
Kernel IPv6 routing table
Destination Next Hop Flags Metric Ref Use Iface
::1/128 :: Un 0 3 12 lo
2001:2001:2001:2001::159/128 :: Un 0 1 0 lo
2001:2001:2001:2001::/64 :: U 256 0 1 eth0
fe80::6020:d7cd:270c:5eb9/128 :: Un 0 1 0 lo
fe80::687d:cbc9:89ed:e5be/128 :: Un 0 2 2340 lo
fe80::9210:74cb:455c:b66e/128 :: Un 0 1 0 lo
fe80::/64 :: U 256 0 0 dummy0
fe80::/64 :: U 256 0 0 wlan0
fe80::/64 :: U 256 0 0 eth0
ff00::/8 :: U 256 2 4 dummy0
ff00::/8 :: U 256 2 9 eth0
ff00::/8 :: U 256 3 4 wlan0
::/0 :: !n -1 1 6 lo添加网关# route -A inet6 add default gw 2001:2001:2001:2001::161如果添加的网关和IP地址不在同一网段,则会报错“SIOCADDRT: No route to host”删除网关
# route -A inet6 del default gw 2001:2001:2001:2001::161
ping测试网络连通
# ping -6 1001:2001:2001:2001::170
PING 1001:2001:2001:2001::170(1001:2001:2001:2001::170) 56 data bytes
64 bytes from 1001:2001:2001:2001::170: icmp_seq=1 ttl=128 time=1.61 ms
64 bytes from 1001:2001:2001:2001::170: icmp_seq=2 ttl=128 time=0.786 ms
64 bytes from 1001:2001:2001:2001::170: icmp_seq=3 ttl=128 time=0.788 ms
^C
--- 1001:2001:2001:2001::170 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.786/1.062/1.614/0.391 ms
查看邻居缓存
# ip -6 neigh show
fe80::34ca:5c49:8f28:8722 dev eth0 lladdr 3c:7c:3f:82:46:9f used 0/0/0 probes 5 STALE
ping6指令
RK3399 Linux系统默认只有ping命令,没有ping6,并且ping -6无法解析Scope:Link地址,
而imx8mq系统的ping6指令是可以解析的。
root@imx8mqevk:~# ping6 --help
BusyBox v1.31.0 (2020-07-01 03:36:16 UTC) multi-call binary.Usage: ping6 [OPTIONS] HOST
ping电脑的Scope:Link地址
root@imx8mqevk:~# ping6 fe80::34ca:5c49:8f28:8722
PING fe80::34ca:5c49:8f28:8722 (fe80::34ca:5c49:8f28:8722): 56 data bytes
64 bytes from fe80::34ca:5c49:8f28:8722: seq=0 ttl=128 time=3.100 ms
64 bytes from fe80::34ca:5c49:8f28:8722: seq=1 ttl=128 time=2.138 ms
64 bytes from fe80::34ca:5c49:8f28:8722: seq=2 ttl=128 time=2.114 ms
修改busybox的编译文件,添加ping6指令
@@ -892,7 +892,7 @@ CONFIG_NSLOOKUP=y# CONFIG_FEATURE_NTPD_SERVER is not set# CONFIG_FEATURE_NTPD_CONF is not setCONFIG_PING=y
-# CONFIG_PING6 is not set
+CONFIG_PING6=yCONFIG_FEATURE_FANCY_PING=y# CONFIG_PSCAN is not setCONFIG_ROUTE=y
经测试,RK3399添加的ping6指令是可以解析Scope:Link地址的。
当ping Scope:Link地址时,当有多个网络节点开启的时候,路由可能会存在冲突:
测试的时候可以将其他的端口down掉,或者在ping的时候指定对应的端口:
简介
参考链接:
https://blog.csdn.net/chao199512/article/details/86139714
IPV4
长度为 32 位(4 个字节)
IPv4 地址的总数为 4 294 967 296 (256 x 256 x 256 x 256)
文本格式为 nnn.nnn.nnn.nnn, 每个 n 都是十进制数
0<=nnn<=255
IPV6
长度为 128 位(16 个字节)
地址的总数 ...
文本格式为 xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx, 每个 x 都是十六进制数
Scope:Link地址和Scope:Global地址
linux中设置的IPv6地址有两种常用的类型,一种是Scope:Global,另一种为Scope:Link。
Scope:Link是由MAC地址通过一定的格式转换出来的全球唯一的以fe80打头的本地链路地址,Linux启动后每个网口启动后都会自动生成一个。
Scope:Global则是我们可以通过命令来设置的。