配置DHCPv6中继示例
组网需求
如图11-18所示,DHCPv6服务器要为两个网段(fc00:1::/64和fc00:2::/64)的主机动态分配IPv6地址和DNS服务器的地址,且DHCPv6服务器与主机不在同一链路。SwitchA上fc00:1::1/64和fc00:2::1/64分别作为fc00:1::/64和fc00:2::/64网段主机的网关地址。
配置思路
在SwitchA上配置DHCPv6中继功能,通过转发DHCPv6服务器和主机之间的DHCPv6报文,以实现主机动态获取IPv6地址和DNS服务器的地址。
配置前请保证DHCPv6服务器与DNS服务器之间路由互通。
操作步骤
- 配置SwitchA作为DHCPv6中继
# 使能DHCP服务。
<HUAWEI> system-view [HUAWEI] sysname SwitchA [SwitchA] dhcp enable
# 配置接口GE0/0/1接口加入VLAN10,接口GE0/0/2接口加入VLAN20,接口GE0/0/3接口加入VLAN30。
[SwitchA] vlan batch 10 20 30 [SwitchA] interface gigabitethernet 0/0/1 [SwitchA-GigabitEthernet0/0/1] port link-type access [SwitchA-GigabitEthernet0/0/1] port default vlan 10 [SwitchA-GigabitEthernet0/0/1] quit [SwitchA] interface gigabitethernet 0/0/2 [SwitchA-GigabitEthernet0/0/2] port link-type trunk [SwitchA-GigabitEthernet0/0/2] port trunk allow-pass vlan 20 [SwitchA-GigabitEthernet0/0/2] quit [SwitchA] interface gigabitethernet 0/0/3 [SwitchA-GigabitEthernet0/0/3] port link-type access [SwitchA-GigabitEthernet0/0/3] port default vlan 30 [SwitchA-GigabitEthernet0/0/3] quit
# 配置VLANIF接口的IPv6地址。
[SwitchA] ipv6 [SwitchA] interface vlanif 10 [SwitchA-Vlanif10] ipv6 enable [SwitchA-Vlanif10] ipv6 address fc00:1::1 64 [SwitchA-Vlanif10] quit [SwitchA] interface vlanif 20 [SwitchA-Vlanif20] ipv6 enable [SwitchA-Vlanif20] ipv6 address fc00:3::1 64 [SwitchA-Vlanif20] quit [SwitchA] interface vlanif 30 [SwitchA-Vlanif30] ipv6 enable [SwitchA-Vlanif30] ipv6 address fc00:2::1 64 [SwitchA-Vlanif30] quit
# 使能DHCPv6中继功能。
[SwitchA] interface vlanif 10 [SwitchA-Vlanif10] dhcpv6 relay destination fc00:3::3 [SwitchA-Vlanif10] quit [SwitchA] interface vlanif 30 [SwitchA-Vlanif30] dhcpv6 relay destination fc00:3::3 [SwitchA-Vlanif30] quit
# 配置SwitchA作为网关向主机发送RA消息的M和O标志位,实现主机通过DHCPv6方式获取IPv6地址。
[SwitchA] interface vlanif 10 [SwitchA-Vlanif10] undo ipv6 nd ra halt [SwitchA-Vlanif10] ipv6 nd autoconfig managed-address-flag [SwitchA-Vlanif10] ipv6 nd autoconfig other-flag [SwitchA-Vlanif10] quit [SwitchA] interface vlanif 30 [SwitchA-Vlanif30] undo ipv6 nd ra halt [SwitchA-Vlanif30] ipv6 nd autoconfig managed-address-flag [SwitchA-Vlanif30] ipv6 nd autoconfig other-flag [SwitchA-Vlanif30] quit
- 配置SwitchB作为DHCPv6服务器
<HUAWEI> system-view [HUAWEI] sysname SwitchB [SwitchB] dhcp enable [SwitchB] ipv6 [SwitchB] vlan 20 [SwitchB-vlan20] quit [SwitchB] interface gigabitethernet 0/0/2 [SwitchB-GigabitEthernet0/0/2] port link-type trunk [SwitchB-GigabitEthernet0/0/2] port trunk allow-pass vlan 20 [SwitchB-GigabitEthernet0/0/2] quit [SwitchB] interface vlanif 20 [SwitchB-Vlanif20] ipv6 enable [SwitchB-Vlanif20] ipv6 address fc00:3::3 64 [SwitchB-Vlanif20] quit [SwitchB] dhcpv6 pool pool1 [SwitchB-dhcpv6-pool-pool1] address prefix fc00:1::/64 [SwitchB-dhcpv6-pool-pool1] excluded-address fc00:1::1 [SwitchB-dhcpv6-pool-pool1] dns-server fc00:4::1 [SwitchB-dhcpv6-pool-pool1] quit [SwitchB] dhcpv6 pool pool2 [SwitchB-dhcpv6-pool-pool2] address prefix fc00:2::/64 [SwitchB-dhcpv6-pool-pool2] excluded-address fc00:2::1 [SwitchB-dhcpv6-pool-pool2] dns-server fc00:4::1 [SwitchB-dhcpv6-pool-pool2] quit [SwitchB] ipv6 route-static :: 0 fc00:3::1
- 配置DHCPv6客户端(PC的操作系统以Windows 7为例)
- 右击桌面“网络”,单击“属性”,进入“网络和共享中心”窗口。
- 单击“本地连接”,进入“本地连接状态”窗口。
- 单击“属性”,进入“本地链接属性”窗口。
- 选择“Internet协议版本6(TCP/IPv6)”,点击“属性”,进入“Internet协议版本6(TCP/IPv6)属性”窗口,选择“自动获得IPv6地址”和“自动获得DNS服务器地址”,单击“确定”。
- 验证配置结果
# 在SwitchA上使用display dhcpv6 relay命令用来查看DHCPv6中继配置情况。
[SwitchA] display dhcpv6 relay -------------------------------------------------------------------------------- Interface Mode Destination -------------------------------------------------------------------------------- Vlanif10 Relay FC00:3::3 Vlanif30 Relay FC00:3::3 -------------------------------------------------------------------------------- Print count : 2 Total count : 2
# 在SwitchB上使用display dhcpv6 pool命令查看DHCPv6地址池的配置信息。[SwitchB] display dhcpv6 pool DHCPv6 pool: pool1 Address prefix: FC00:1::/64 Lifetime valid 172800 seconds, preferred 86400 seconds 4 in use, 0 conflicts excluded-address FC00:1::1 1 excluded addresses Information refresh time: 86400 DNS server address: FC00:4::1 conflict-address expire-time: 172800 renew-time-percent : 50 rebind-time-percent : 80 Active normal clients: 4 Logging : Disable DHCPv6 pool: pool2 Address prefix: FC00:2::/64 Lifetime valid 172800 seconds, preferred 86400 seconds 2 in use, 0 conflicts excluded-address FC00:2::1 1 excluded addresses Information refresh time: 86400 DNS server address: FC00:4::1 conflict-address expire-time: 172800 renew-time-percent : 50 rebind-time-percent : 80 Active normal clients: 2 Logging : Disable Total of dhcpv6 pool : 2
# 分别在SwitchB上使用命令display dhcpv6 pool pool1 allocated address和display dhcpv6 pool pool2 allocated address查看DHCPv6地址池的IPv6地址分配情况。[SwitchB] display dhcpv6 pool pool1 allocated address Address Valid Expires Left ------------------------------------------------------------------------------- FC00:1::2 172800 2013-09-06 03:09:02 166610 FC00:1::3 172800 2013-09-06 03:09:02 166610 FC00:1::4 172800 2013-09-06 03:09:02 166610 FC00:1::5 172800 2013-09-06 03:09:02 166610 ------------------------------------------------------------------------------- Total : 4
[SwitchB] display dhcpv6 pool pool2 allocated address Address Valid Expires Left ------------------------------------------------------------------------------- FC00:2::2 172800 2013-09-06 03:09:02 166610 FC00:2::3 172800 2013-09-06 03:09:02 166610 ------------------------------------------------------------------------------- Total : 2
配置文件
SwitchA的配置文件
# sysname SwitchA # ipv6 # vlan batch 10 20 30 # dhcp enable # interface Vlanif10 ipv6 enable ipv6 address FC00:1::1/64 undo ipv6 nd ra halt ipv6 nd autoconfig managed-address-flag ipv6 nd autoconfig other-flag dhcpv6 relay destination FC00:3::3 # interface Vlanif20 ipv6 enable ipv6 address FC00:3::1/64 # interface Vlanif30 ipv6 enable ipv6 address FC00:2::1/64 undo ipv6 nd ra halt ipv6 nd autoconfig managed-address-flag ipv6 nd autoconfig other-flag dhcpv6 relay destination FC00:3::3 # interface GigabitEthernet0/0/1 port link-type access port default vlan 10 # interface GigabitEthernet0/0/2 port link-type trunk port trunk allow-pass vlan 20 # interface GigabitEthernet0/0/3 port link-type access port default vlan 30 # return
SwitchB的配置文件
# sysname SwitchB # ipv6 # vlan batch 20 # dhcp enable # dhcpv6 pool pool1 address prefix FC00:1::/64 excluded-address FC00:1::1 dns-server FC00:4::1 # dhcpv6 pool pool2 address prefix FC00:2::/64 excluded-address FC00:2::1 dns-server FC00:4::1 # interface Vlanif20 ipv6 enable ipv6 address FC00:3::3/64 # interface GigabitEthernet0/0/2 port link-type trunk port trunk allow-pass vlan 20 # ipv6 route-static :: 0 FC00:3::1 # return