1、环境试验准备
拓扑图
实验过程
①给路由器R1与R2互联接口添加IPv6地址,添加完成后查看邻居关系并测试连通性
②在路由器R1与R2上创建DHCPv6,使PC进行有状态地址配置
IPv4格式:X.X.X.X
IPv6地址格式:X:X:X:X:X:X:X:X
说明:IPv4使用的格式为点分十进制,4组8位,总计32bit。而IPv6使用的地址格式为冒分十六进制,8组16位,总计128bit。
1、给R1添加IPv6地址
给R1的GigabitEthernet0/0/0添加IPv6全球单播地址
[R1]interface GigabitEthernet0/0/0 \\进入与R2互联的接口
[R1-GigabitEthernet0/0/0]ipv6 enable \\开启接口IPv6功能
[R1-GigabitEthernet0/0/0]ipv6 address 2409:65cd:1a6c::1 64 \\添加前缀为2409:65CD:1A6C:0000::/64的IPv6地址
//以下为系统提示消息
Jan 16 2023 14:41:09-08:00 R1 IPV6/2/IF_IPV6CHANGE:OID 16777216.50331648.1006632
96.16777216.33554432.16777216.922746880.33554432.0.16777216 The status of the IP
v6 Interface changed. (IfIndex=50331648, IfDescr=HUAWEI, AR Series, GigabitEther
net0/0/0 Interface, IfOperStatus=16777216, IfAdminStatus=16777216)
Jan 16 2023 14:41:09-08:00 R1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IPv
6 on the interface GigabitEthernet0/0/0 has entered the UP state.
地址添加完成后我们查看接口地址情况
查看R1地址的配置情况
[R1]display ipv6 int brief
*down: administratively down
(l): loopback
(s): spoofing
Interface Physical Protocol
GigabitEthernet0/0/0 up up
[IPv6 Address] 2409:65CD:1A6C::1
从上面这段代码我们可以看出IPv6地址已经成功添加,并且交换机接口G0口IPv6协议已经UP
2、给R2添加IPv6地址
给R2的GigabitEthernet0/0/0添加IPv6全球单播地址
[R2]int GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]ipv6 address 2409:65cd:1a6c::2 64
[R2-GigabitEthernet0/0/0]ipv6 enable
//以下为系统提示消息
Jan 16 2023 15:07:26-08:00 Huawei IPV6/2/IF_IPV6CHANGE:OID 16777216.50331648.100
663296.16777216.33554432.16777216.922746880.33554432.0.16777216 The status of th
e IPv6 Interface changed. (IfIndex=50331648, IfDescr=HUAWEI, AR Series, GigabitE
thernet0/0/0 Interface, IfOperStatus=16777216, IfAdminStatus=16777216)
Jan 16 2023 15:07:26-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[1]:The line protocol
IPv6 on the interface GigabitEthernet0/0/0 has entered the UP state.
查看R2地址的配置情况
[R2]display ipv6 int brief
*down: administratively down
(l): loopback
(s): spoofing
Interface Physical Protocol
GigabitEthernet0/0/0 up up
[IPv6 Address] 2409:65CD:1A6C::2
2、给交换机添加链路本地地址
说明:链路本地地址的有限范围为本地链路,每一个IPv6接口都必须具备一个链路本地地址,通过EUI-64的方式自动生成链路本地地址,这种生成方式非常简单,就是在MAC地址中间插入FFFE。
[R1-GigabitEthernet0/0/0]ipv6 address auto link-local \\为接口添加链路本地地址
[R2-GigabitEthernet0/0/0]ipv6 address auto link-local \\为接口添加链路本地地址
查看邻居状态
[R1]display ipv6 neighbors
-----------------------------------------------------------------------------
IPv6 Address : 2409:65CD:1A6C::2
Link-layer : 00e0-fc9d-78da State : REACH
Interface : GE0/0/0 Age : 0
VLAN : - CEVLAN: -
VPN name : Is Router: TRUE
Secure FLAG : UN-SECURE
IPv6 Address : FE80::2E0:FCFF:FE9D:78DA
Link-layer : 00e0-fc9d-78da State : DELAY
Interface : GE0/0/0 Age : 22
VLAN : - CEVLAN: -
VPN name : Is Router: TRUE
Secure FLAG : UN-SECURE
-----------------------------------------------------------------------------
Total: 2 Dynamic: 2 Static: 0
[R2-GigabitEthernet0/0/0]display ipv6 neighbors
-----------------------------------------------------------------------------
IPv6 Address : 2409:65CD:1A6C::1
Link-layer : 00e0-fc31-4a06 State : STALE
Interface : GE0/0/0 Age : 0
VLAN : - CEVLAN: -
VPN name : Is Router: TRUE
Secure FLAG : UN-SECURE
IPv6 Address : FE80::2E0:FCFF:FE31:4A06
Link-layer : 00e0-fc31-4a06 State : STALE
Interface : GE0/0/0 Age : 0
VLAN : - CEVLAN: -
VPN name : Is Router: TRUE
Secure FLAG : UN-SECURE
-----------------------------------------------------------------------------
Total: 2 Dynamic: 2 Static: 0
测试连通性
[R1]ping ipv6 2409:65CD:1A6C::2
PING 2409:65CD:1A6C::2 : 56 data bytes, press CTRL_C to break
Reply from 2409:65CD:1A6C::2
bytes=56 Sequence=1 hop limit=64 time = 30 ms
Reply from 2409:65CD:1A6C::2
bytes=56 Sequence=2 hop limit=64 time = 20 ms
Reply from 2409:65CD:1A6C::2
bytes=56 Sequence=3 hop limit=64 time = 30 ms
Reply from 2409:65CD:1A6C::2
bytes=56 Sequence=4 hop limit=64 time = 20 ms
Reply from 2409:65CD:1A6C::2
bytes=56 Sequence=5 hop limit=64 time = 20 ms
--- 2409:65CD:1A6C::2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/24/30 ms
[R1]ping ipv6 FE80::2E0:FCFF:FE9D:78DA -i GigabitEthernet 0/0/0
PING FE80::2E0:FCFF:FE9D:78DA : 56 data bytes, press CTRL_C to break
Reply from FE80::2E0:FCFF:FE9D:78DA
bytes=56 Sequence=1 hop limit=64 time = 30 ms
Reply from FE80::2E0:FCFF:FE9D:78DA
bytes=56 Sequence=2 hop limit=64 time = 20 ms
Reply from FE80::2E0:FCFF:FE9D:78DA
bytes=56 Sequence=3 hop limit=64 time = 10 ms
Reply from FE80::2E0:FCFF:FE9D:78DA
bytes=56 Sequence=4 hop limit=64 time = 20 ms
Reply from FE80::2E0:FCFF:FE9D:78DA
bytes=56 Sequence=5 hop limit=64 time = 20 ms
--- FE80::2E0:FCFF:FE9D:78DA ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 10/20/30 ms
注意:测试链路本地地址的时候需要指定接口,因为链路本地地址仅在本地链路有效
3、创建DHCPv6地址池
在此我先介绍一下什么是有状态地址配置取和无状态地址配置
- 有状态地址配置(DHCPv6),M=1,O=1
- 采用DHCPv6协议,IPv6客户端从DHCPv6服务器获取完整的128bit IPv6地址,同时获取的包括DNS,SNTP服务器(SNTP,简单网络时钟协议)等地址参数
- DHCPv6还会记录地址分配状态,这也是为什么称为有状态的原因
- 无状态地址配置
- 采用ICMPv6协议,使能了ICMPv6的RA功能(RA,路由器通告报文)的路由器会周期性的通告该链路上的IPv6前缀。
- 主机根据路由器回应的RA报文获取IPv6前缀信息,并使用该地址前缀,加上本地产生的接口标识,形成单薄IPv6地址。
- 无状态地址配置不会关心主机的状态如何,比如是否在线,这也是为什么称为无状态的原因
创建DHCPv6地址池,配置如下
[R1]dhcpv6 pool test
[R1-dhcpv6-pool-test]address prefix 2001:165d::/64 \\向地址池内添加前缀为2001:165D:0000:0000::/64的网段
[R1-dhcpv6-pool-test]excluded-address 2001:165d::1 \\排除网关地址
[R1-dhcpv6-pool-test]dns-server 2001:1753:48:3:5:: \\发布DNS
[R1-dhcpv6-pool-test]quit
[R1]dhcp enable \\全局开启DHCP,如未开启则DHCPv6服务无法正常使用
[R1]interface GigabitEthernet0/0/1
[R1-GigabitEthernet0/0/1]ipv6 address 2001:165D::1/64 \\添加IPv6地址作为网关
[R1-GigabitEthernet0/0/1]dhcpv6 server test \\将刚才创建的名为test的DHCPv6地址池应用在接口上
[R1-GigabitEthernet0/0/1]undo ipv6 nd ra halt \\取消抑制系统发布的RA报文
[R1-GigabitEthernet0/0/1]ipv6 nd autoconfig managed-address-flag \\设置RA报文中的有状态自动配置地址的标志位
[R1-GigabitEthernet0/0/1]ipv6 nd autoconfig other-flag \\设置RA报文中的有状态自动配置其他信息的标志位
接下来PC设置为DHCPv6自动获取
查看地址获取情况
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fefc:369f
IPv6 address......................: 2001:165d::2 / 128
IPv6 gateway......................: fe80::2e0:fcff:fe31:4a07
IPv4 address......................: 0.0.0.0
Subnet mask.......................: 0.0.0.0
Gateway...........................: 0.0.0.0
Physical address..................: 54-89-98-FC-36-9F
DNS server........................:
地址获取正常,但是没有DNS,静态配置也没有DNS的复选框,那么可以判断是软件没有开发出这个功能。查看R1的地址分配情况
[R1]display dhcpv6 pool test
DHCPv6 pool: test
Address prefix: 2001:165D::/64
Lifetime valid 172800 seconds, preferred 86400 seconds
1 in use, 0 conflicts
Excluded-address 2001:165D::1
1 excluded addresses
Information refresh time: 86400
DNS server address: 2001:1753:48:3:5::
Conflict-address expire-time: 172800
Active normal clients: 1
可以看到已经分配出去了一个地址
在此我再讲一下地址冲突的问题,在IPv4中,我们有免费arp可以进行地址冲突检查,那么在IPv6中我们使用DAD(Duplicate address detection重复地址检测)来检测地址是否已存在;
假设R1使用了2001::FFFF/64的地址,此时PC1上线,也使用了同样的地址,那么在正式使用这个地址之前,PC1会对这个地址进行DAD的检查,
过程如下
①PC1以组播的方式向R1发送一个NS报文,该NS的源IPv6地址为"::",目的IPv6地址为要进行DAD的2001::FFFF对应的被请求节点组播地址,也就是FF02::1:FF00:FFFF,这个NS中包括着要做DAD的目标地址2001::FFFF,那么这个被请求节点组播地址地址是如何算出来的呢,公式如下:
104固定前缀+拷贝源地址的最后24bit, 得出此地址的被请求节点组播地址。
接下来咱们继续讲DAD
②链路上的节点都会收到这个组播的NS报文,没有配置2001::1的节点接口由于没有加入该地址对应的被请求节点组播组,因此在收到此NS的时候会进行丢弃,而R1在收到这个NS报文后,由于它的接口配置了2001::FFFF,因此会加入该请求节点组播组,而此刻收到的报文以该地址为目的地址,因此他会解析此报文,当R1发现对方进行DAD的地址与本地接口地址相同时,会立马回应一个NA报文,该报文的目的地址为FF02::1,也就是所有节点的组播地址,同时在报文内写入目标地址2001::FFFF,以及自己的接口的MAC地址。
③当PC收到这个NA报文后,它就知道2001::FFFF在链路上已经有人在用了,因此将改地址标记为重复地址,改地址将不能用于通信。若未收到NA报文,则PC判断这个IPv6地址可以使用。
说明:常用的预留组播地址有 FF02::1(链路本地范围所有节点组播地址)、FF02::2(链路本地范围所有路由器组播地址)等。
IPv6中的DAD类似于IPv4中的免费ARP。