H3C交换机配置DHCPv6服务器
官方文档:https://www.h3c.com/cn/d_202303/1810058_30005_0.htm
IPv6地址计算器:https://www.838dz.com/calculator/5233.html
配置调试
场景
- 将Router模拟为运营商链路
- 将Switch模拟为DHCPv6服务器
- 实现PC可以从Switch上获取ipv6地址实现上网
拓扑
基本配置
- ISP部分
<H3C>sys
System View: return to User View with Ctrl+Z.
[H3C]sysname Router
[Router]interface Gigabitethernet 1/0
[Router-GigabitEthernet1/0]ipv6 address 2001:: 127
# 配置环回口为下一跳地址
[Router]interface LoopBack 0
[Router-LoopBack0]ipv6 address 2400:3200::1 128
# 下联为交换机配置下联主机回程路由
[Router]ipv6 route-static 2001:2001:: 64 2001::1
- Switch基础部分
# 配置各接口地址以及出口路由
<H3C>sys
System View: return to User View with Ctrl+Z.
[H3C]sysname Switch
[Switch]interface GigabitEthernet1/0
[Switch-GigabitEthernet1/0]ipv6 address 2001::1 127
[Switch]interface GigabitEthernet2/0
[Switch-GigabitEthernet2/0]ipv6 address 2001:2001::1 64
[Switch-GigabitEthernet2/0]quit
[Switch]ipv6 route-static :: 0 2001::
# 测试与Router下一条连通性
[Switch]ping ipv6 2400:3200::1
Ping6(56 data bytes) 2001::1 --> 2400:3200::1, press CTRL_C to break
56 bytes from 2400:3200::1, icmp_seq=0 hlim=64 time=3.239 ms
56 bytes from 2400:3200::1, icmp_seq=1 hlim=64 time=1.430 ms
56 bytes from 2400:3200::1, icmp_seq=2 hlim=64 time=0.872 ms
56 bytes from 2400:3200::1, icmp_seq=3 hlim=64 time=0.990 ms
56 bytes from 2400:3200::1, icmp_seq=4 hlim=64 time=0.972 ms
--- Ping6 statistics for 2400:3200::1 ---
5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss
round-trip min/avg/max/std-dev = 0.872/1.501/3.239/0.890 ms
- Switch DHCPv6部分
# 配置ipv6地址池前缀
ipv6 dhcp prefix-pool 64 prefix 2001:2001::/64 assign-len 64
# 配置IPv6地址池
[Switch]ipv6 dhcp pool ipv6
[Switch-dhcp6-pool-ipv6]network 2001:2001::/64
[Switch-dhcp6-pool-ipv6]prefix-pool 64
[Switch-dhcp6-pool-ipv6]gateway-list 2001:2001::1
[Switch-dhcp6-pool-ipv6]dns-server 2400:3200::1
# 配置IPv6排除地址
[Switch]ipv6 dhcp server forbidden-address 2001:2001::1
# 接口使能DHCPv6
[Switch]interface GigabitEthernet 2/0
# 取消设备发布RA消息的抑制。主机通过DHCPv6服务器获取IPv6地址。主机通过DHCPv6服务器获取除IPv6地址以外的其他信息
[Switch-GigabitEthernet2/0]undo ipv6 nd ra halt
[Switch-GigabitEthernet2/0]ipv6 nd autoconfig other-flag
[Switch-GigabitEthernet2/0]ipv6 nd autoconfig managed-address-flag
[Switch-GigabitEthernet2/0]ipv6 dhcp select server
[Switch-GigabitEthernet2/0]ipv6 dhcp server apply pool ipv6
- PC部分
# 因为vpc不能获取dhcpv6地址,这里拿Router做下实验
<H3C>sys
System View: return to User View with Ctrl+Z.
[H3C]sysname PC
[PC]int
[PC]interface g
[PC]interface GigabitEthernet 1/0
[PC-GigabitEthernet1/0]ipv6 address dhcp-alloc
[PC-GigabitEthernet1/0]dis ipv6 interface brief
*down: administratively down
(s): spoofing
Interface Physical Protocol IPv6 Address
GigabitEthernet1/0 up up 2001:2001::2
[PC-GigabitEthernet1/0]
# 以上是已经获取到了dhcpv6地址,到Switch上验证一下
[Switch]dis ipv6 dhcp server ip-in-use
Pool: ipv6
IPv6 address Type Lease expiration
2001:2001::2 Auto(C) May 6 09:36:36 2024
# 回到PC这,添加一条静态路由,并验证
[PC-GigabitEthernet1/0]ipv6 route-static :: 0 2001:2001::1
[PC]ping ipv6 2400:3200::1
Ping6(56 data bytes) 2001:2001::2 --> 2400:3200::1, press CTRL+C to break
56 bytes from 2400:3200::1, icmp_seq=0 hlim=63 time=2.401 ms
56 bytes from 2400:3200::1, icmp_seq=1 hlim=63 time=2.154 ms
56 bytes from 2400:3200::1, icmp_seq=2 hlim=63 time=5.090 ms
56 bytes from 2400:3200::1, icmp_seq=3 hlim=63 time=2.055 ms
56 bytes from 2400:3200::1, icmp_seq=4 hlim=63 time=1.235 ms
--- Ping6 statistics for 2400:3200::1 ---
5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss
round-trip min/avg/max/std-dev = 1.235/2.587/5.090/1.311 ms
[PC]
- DHCPv6附加参数(可选)
常用的就是限制租约时间,这里举个例子:
配置 network 2001:2001::/64网段内的地址租约时长为691200秒(8天)有效时长为691200秒(8天)
# 配置IPv6地址池
[Switch]ipv6 dhcp pool ipv6
[Switch-dhcp6-pool-ipv6]network 2001:2001::/64 preferred-lifetime 691200 valid-lifetime 691200
[Switch-dhcp6-pool-ipv6]prefix-pool 64
[Switch-dhcp6-pool-ipv6]gateway-list 2001:2001::1
[Switch-dhcp6-pool-ipv6]dns-server 2400:3200::1
标签:H3C,3200,ipv6,Switch,2001,64,2400,IPv6,DHCP
From: https://www.cnblogs.com/mo-x/p/18117138