As shown in Figure 1, SwitchA and SwitchB are located on the same link. SwitchA is deployed as the DHCPv6 server and SwitchB is deployed as the DHCPv6 client to enable SwitchB to obtain an IPv6 address and DNS server address through the DHCPv6 server.
On SwitchA, configure the DHCPv6 server function so that the DHCPv6 server can dynamically assign the IPv6 address and DNS server address to the DHCPv6 client. Configure IPv6 addresses for interfaces, configure an IPv6 address pool, and enable the DHCPv6 server function on the interfaces.
On SwitchB, configure the DHCPv6 client function so that the DHCPv6 client can dynamically obtain the IPv6 address and DNS server address through the DHCPv6 server. Configure the IPv6 function and enable the DHCPv6 client function on the interfaces.
Ensure that the DHCPv6 and DNS servers are routable to each other before the configuration.
# Configure an IPv6 address for the interface.
<HUAWEI> system-view [HUAWEI] sysname SwitchA [SwitchA] ipv6 [SwitchA] vlan 100 [SwitchA-vlan100] quit [SwitchA] interface gigabitethernet 0/0/1 [SwitchA-GigabitEthernet0/0/1] port link-type trunk [SwitchA-GigabitEthernet0/0/1] port trunk allow-pass vlan 100 [SwitchA-GigabitEthernet0/0/1] quit [SwitchA] interface vlanif 100 [SwitchA-Vlanif100] ipv6 enable [SwitchA-Vlanif100] ipv6 address fc00:3::1/64 [SwitchA-Vlanif100] quit
# Configure an IPv6 address pool.
[SwitchA] dhcpv6 pool pool1 [SwitchA-dhcpv6-pool-pool1] address prefix fc00:3::/64 [SwitchA-dhcpv6-pool-pool1] excluded-address fc00:3::1 [SwitchA-dhcpv6-pool-pool1] dns-server fc00:4::1 [SwitchA-dhcpv6-pool-pool1] quit
# Enable the DHCPv6 server function on the interface.
[SwitchA] dhcp enable [SwitchA] interface vlanif 100 [SwitchA-Vlanif100] dhcpv6 server pool1
# Enable the RA message advertisement function to make the DHCPv6 client learn the default route destined for the IPv6 gateway through RA messages. Configure the M and O flags of the advertised RA messages to make the DHCPv6 client obtain an IPv6 address and other network parameters using DHCP.
[SwitchA-Vlanif100] undo ipv6 nd ra halt [SwitchA-Vlanif100] ipv6 nd autoconfig managed-address-flag [SwitchA-Vlanif100] ipv6 nd autoconfig other-flag [SwitchA-Vlanif100] quit [SwitchA] quit
# Configure the IPv6 function on the interface.
<HUAWEI> system-view [HUAWEI] sysname SwitchB [SwitchB] ipv6 [SwitchB] vlan 100 [SwitchB-vlan100] quit [SwitchB] interface gigabitethernet 0/0/1 [SwitchB-GigabitEthernet0/0/1] port link-type trunk [SwitchB-GigabitEthernet0/0/1] port trunk allow-pass vlan 100 [SwitchB-GigabitEthernet0/0/1] quit [SwitchB] interface vlanif 100 [SwitchB-Vlanif100] ipv6 enable [SwitchB-Vlanif100] ipv6 address auto link-local
# Enable the DHCPv6 client function on the interface.
[SwitchB-Vlanif100] ipv6 address auto dhcp
# Configure the DHCPv6 client to learn the default route destined for the IPv6 gateway through RA messages.
[SwitchB-Vlanif100] ipv6 address auto global default [SwitchB-Vlanif100] quit [SwitchB] quit
# On SwitchA, run the display dhcpv6 pool command to check the configuration and address assignment of the IPv6 address pool pool1.
<SwitchA> display dhcpv6 pool pool1
DHCPv6 pool: pool1
Address prefix: FC00:3::/64
Lifetime valid 172800 seconds, preferred 86400 seconds
1 in use, 0 conflicts
excluded-address FC00:3::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: 1
Logging : Disable
<SwitchA> display dhcpv6 pool pool1 allocated address Address Valid Expires Left ------------------------------------------------------------------------------- FC00:3::2 172800 2014-03-29 05:47:19 159594 ------------------------------------------------------------------------------- Total : 1
# On SwitchA, run the display ipv6 interface vlanif 100 command to check the IPv6 link-local address of VLANIF 100, so that you can further check whether the default route destined for the IPv6 gateway is generated on the DHCPv6 client.
<SwitchA> display ipv6 interface vlanif 100 Vlanif100 current state : UP IPv6 protocol current state : UP IPv6 is enabled, link-local address is FE80::2EAB:FF:FE98:15BB Global unicast address(es): FC00:3::1, subnet is FC00:3::/64 Joined group address(es): FF02::1:2 FF02::1:FF00:1 FF02::1:FF98:15BB FF02::2 FF02::1 ……
# On SwitchB, run the display dhcpv6 client command to check the DHCPv6 client configuration.
<SwitchB> display dhcpv6 client Vlanif100 is in stateful DHCPv6 client mode. Stateful DHCPv6 client is in BOUND state. Preferred server DUID : 00030001000B099C1162 Reachable via address : FE80::20B:9FF:FE03:AC9B IA NA IA ID 0x000004E1 T1 43200 T2 69120 Obtained : 2014-03-26 17:47:15 Renews : 2014-03-27 05:47:15 Rebinds : 2014-03-27 12:59:15 Address : FC00:3::2 Lifetime valid 172800 seconds, preferred 86400 seconds Expires at 2014-03-28 17:47:15(172726 seconds left) DNS server : FC00:4::1
# On SwitchB, run the display ipv6 routing-table command to check the default route destined for the IPv6 gateway on the DHCPv6 client.
<SwitchB> display ipv6 routing-table Routing Table : Public Destinations : 4 Routes : 4 Destination : :: PrefixLength : 0 NextHop : FE80::2EAB:FF:FE98:15BB Preference : 64 Cost : 0 Protocol : Unr RelayNextHop : :: TunnelID : 0x0 Interface : Vlanif100 Flags : D Destination : ::1 PrefixLength : 128 NextHop : ::1 Preference : 0 Cost : 0 Protocol : Direct RelayNextHop : :: TunnelID : 0x0 Interface : InLoopBack0 Flags : D Destination : FC00:3::2 PrefixLength : 128 NextHop : ::1 Preference : 0 Cost : 0 Protocol : Direct RelayNextHop : :: TunnelID : 0x0 Interface : Vlanif100 Flags : D Destination : FE80:: PrefixLength : 10 NextHop : :: Preference : 0 Cost : 0 Protocol : Direct RelayNextHop : :: TunnelID : 0x0 Interface : NULL0 Flags : D
SwitchA configuration file
#
sysname SwitchA
#
ipv6
#
vlan batch 100
#
dhcp enable
#
dhcpv6 pool pool1
address prefix FC00:3::/64
excluded-address FC00:3::1
dns-server FC00:4::1
#
interface Vlanif100
ipv6 enable
ipv6 address FC00:3::1/64
undo ipv6 nd ra halt
ipv6 nd autoconfig managed-address-flag
ipv6 nd autoconfig other-flag
dhcpv6 server pool1
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 100
#
return
SwitchB configuration file
#
sysname SwitchB
#
ipv6
#
vlan batch 100
#
interface Vlanif100
ipv6 enable
ipv6 address auto link-local
ipv6 address auto global default
ipv6 address auto dhcp
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 100
#
return