As shown in Figure 1, the DHCPv6 server needs to dynamically assign IPv6 addresses and DNS server addresses to the clients on network segments fc00:1::/64 and fc00:2::/64, and the DHCPv6 server and clients are on different links. The addresses fc00:1::1/64 and fc00:2::1/64 on SwitchA are used as the gateway addresses of the clients on the network segments fc00:1::/64 and fc00:2::/64.
Configure the DHCPv6 relay function on SwitchA to forward DHCPv6 packets between the DHCPv6 server and clients, so that the clients can dynamically obtain IPv6 addresses and DNS server addresses.
Ensure that the DHCPv6 and DNS servers are routable to each other before the configuration.
# Enable the DHCP service.
<HUAWEI> system-view [HUAWEI] sysname SwitchA [SwitchA] dhcp enable
# Add GE0/0/1 to VLAN 10, GE0/0/2 to VLAN 20, and GE0/0/3 to VLAN 30.
[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
# Configure IPv6 addresses of VLANIF interfaces.
[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
# Enable the DHCPv6 relay function.
[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
# Configure SwitchA to function as a gateway to send the M and O flags of RA messages to clients so that the clients can obtain IPv6 addresses through DHCPv6.
[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
<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
# Run the display dhcpv6 relay command on SwitchA to check the DHCPv6 relay configuration.
[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 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 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 configuration file
# 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 configuration file
# 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