- Table of Contents
-
- H3C Campus Fixed-Port Switches CLI-Based Quick Start Configuration Guide -6W102
- 01-H3C Devices CLI Reference
- 02-Login Management Quick Start Configuration Guide
- 03-Configuration File Management Quick Start Configruation Guide
- 04-Software Upgrade Quick Start Configuration Guide
- 05-Device Management Quick Start Configuration Guide
- 06-NTP Quick Start Configuration Guide
- 07-RBAC Quick Start Configuration Guide
- 08-IRF Quick Start Configuration Guide
- 09-Ethernet Interface Quick Start Configuration Guide
- 10-VLAN Quick Start Configuration Guide
- 11-Port Isolation Quick Start Configuration Guide
- 12-Loop Detection Quick Start Configuration Guide
- 13-QinQ Quick Start Configuration Guide
- 14-MAC Address Table Quick Start Configuration Guide
- 15-Ethernet Link Aggregation Quick Start Configuration Guide
- 16-Spanning Tree Quick Start Configuration Guide
- 17-DHCP Quick Start Configuration Guide
- 18-OSPF Quick Start Configuration Guide
- 19-Static Routing Quick Start Configuration Guide
- 20-Basic RIP Quick Start Configuration Guide
- 21-PBR Quick Start Configuration Guide
- 22-IGMP Snooping Quick Start Configuration Guide
- 23-Packet Filtering Quick Start Configuration Guide
- 24-QoS Quick Start Configuration Guide
- 25-IP Source Guard Quick Start Configuration Guide
- 26-SSH Quick Start Configuration Guide
- 27-Port Security Quick Start Configuration Guide
- 28-VRRP Quick Start Configuration Guide
- 29-PoE Quick Start Configuration Guide
- 30-Mirroring Quick Start Configuration Guide
- 31-Information Center Quick Start Configuration Guide
- 32-SNMP Quick Start Configuration Guide
- 33-Static Route-Based Public and Private Network Intercommunication Configuration Guide
- 34-LAN Networks Quick Start Configuration Guide
- 35-802.1X Quick Start Configuration Guide
- 36-AAA Quick Start Configuration Guide
- Related Documents
-
Title | Size | Download |
---|---|---|
17-DHCP Quick Start Configuration Guide | 253.57 KB |
DHCP Quick Start Configuration Guide
Copyright © 2025 New H3C Technologies Co., Ltd. All rights reserved.
No part of this manual may be reproduced or transmitted in any form or by any means without prior written consent of New H3C Technologies Co., Ltd.
Except for the trademarks of New H3C Technologies Co., Ltd., any trademarks that may be mentioned in this document are the property of their respective owners.
The information in this document is subject to change without notice.
Configuring dynamic IPv4 address assignment
Introduction
The following example describes the basic procedure to configure an interface as a DHCP server for dynamic IPv4 address assignment.
Network configuration
As shown in Figure 1, the core switch has three VLANs. Host A, Host B, and Host C are in VLAN 5, VLAN 6, and VLAN 7, respectively. Configure the core switch as a DHCP server to meet the following requirements:
· The clients on subnets 192.168.5.0/24, 192.168.6.0/24, and 192.168.7.0/24 can obtain IP addresses through DHCP.
· The IP addresses of VLAN-interface 5, VLAN-interface 6, and VLAN-interface 7 on the switch are 192.168.5.254/24, 192.168.6.254/24, and 192.168.7.254/24, respectively.
· For the hosts in subnet 192.168.5.0/24, the DNS server IP address is 192.168.5.100 and the gateway IP address is 192.168.5.254/24.
· For the hosts in subnet 192.168.6.0/24, the DNS server IP address is 192.168.6.100 and the gateway IP address is 192.168.6.254/24.
· For the hosts in subnet 192.168.7.0/24, the DNS server IP address is 192.168.7.100 and the gateway IP address is 192.168.7.254/24.
Procedure
<Switch> system-view
[Switch] vlan 5
[Switch-vlan5] port gigabitEthernet 1/0/5
[Switch-vlan5] quit
[Switch]vlan 6
[Switch-vlan6] port gigabitEthernet 1/0/6
[Switch-vlan6] quit
[Switch]vlan 7
[Switch-vlan7] port gigabitEthernet 1/0/7
[Switch-vlan7] quit
# Assign IP addresses to VLAN-interface 5, VLAN-interface 6, and VLAN-interface 7. Each VLAN interface acts as the gateway in the VLAN to which the interface belongs.
[Switch] interface vlan-interface 5
[Switch-Vlan-interface5] ip address 192.168.5.254 255.255.255.0
[Switch-Vlan-interface5] quit
[Switch]interface vlan-interface 6
[Switch-Vlan-interface6] ip address 192.168.6.254 255.255.255.0
[Switch-Vlan-interface6] quit
[Switch]interface vlan-interface 7
[Switch-Vlan-interface7] ip address 192.168.7.254 255.255.255.0
[Switch-Vlan-interface7] quit
# (Optional.) Exclude specific IP addresses (such as DNS server IP addresses) from dynamic IP address assignment.
[Switch] dhcp server forbidden-ip 192.168.5.100
[Switch] dhcp server forbidden-ip 192.168.6.100
[Switch] dhcp server forbidden-ip 192.168.7.100
# Create IP address pool 5 to assign IP addresses to the clients on subnet 192.168.5.0/24.
[Switch] dhcp server ip-pool 5
[Switch-dhcp-pool-5] network 192.168.5.0 mask 255.255.255.0
[Switch-dhcp-pool-5] dns-list 192.168.5.100
[Switch-dhcp-pool-5] gateway-list 192.168.5.254
[Switch-dhcp-pool-5] quit
# Create IP address pool 6 to assign IP addresses to the clients on subnet 192.168.6.0/24.
[Switch] dhcp server ip-pool 6
[Switch-dhcp-pool-6] network 192.168.6.0 mask 255.255.255.0
[Switch-dhcp-pool-6] dns-list 192.168.6.100
[Switch-dhcp-pool-6] gateway-list 192.168.6.254
[Switch-dhcp-pool-6] quit
# Create IP address pool 7 to assign IP addresses to the clients on subnet 192.168.7.0/24.
[Switch] dhcp server ip-pool 7
[Switch-dhcp-pool-7] network 192.168.7.0 mask 255.255.255.0
[Switch-dhcp-pool-7] dns-list 192.168.7.100
[Switch-dhcp-pool-7] gateway-list 192.168.7.254
[Switch-dhcp-pool-7] quit
# Enable DHCP on the switch.
[Switch] dhcp enable
# Enable VLAN-interface 5, VLAN-interface 6, and VLAN-interface 7 to operate in DHCP server mode, respectively.
[Switch] interface vlan-interface 5
[Switch-Vlan-interface5] dhcp select server
[Switch-Vlan-interface5] quit
[Switch] interface vlan-interface 6
[Switch-Vlan-interface6] dhcp select server
[Switch-Vlan-interface6] quit
[Switch] interface vlan-interface 7
[Switch-Vlan-interface7] dhcp select server
[Switch-Vlan-interface7] quit
Verifying the configuration
Verify that the DHCP server can assign IP addresses and other network settings to the clients on subnets 192.168.5.0/24, 192.168.6.0/24, and 192.168.7.0/24 correctly.
1. View the DHCP server configuration.
# Use the display dhcp server pool command to view DHCP address pool information.
[Switch] display dhcp server pool
Pool name: 5
Network: 192.168.5.0 mask 255.255.255.0
dns-list 192.168.5.100
expired day 1 hour 0 minute 0 second 0
gateway-list 192.168.5.254
IP-in-use threshold 100
Pool name: 6
Network: 192.168.6.0 mask 255.255.255.0
dns-list 192.168.6.100
expired day 1 hour 0 minute 0 second 0
gateway-list 192.168.6.254
IP-in-use threshold 100
Pool name: 7
Network: 192.168.7.0 mask 255.255.255.0
dns-list 192.168.7.100
expired day 1 hour 0 minute 0 second 0
gateway-list 192.168.7.254
IP-in-use threshold 100
2. View the IP addresses assigned by the DHCP server.
# Use the display dhcp server ip-in-use command to view the IP addresses assigned by the DHCP server.
[Switch] display dhcp server ip-in-use
IP address Client-identifier/ Lease expiration Type
Hardware address
192.168.5.1 0262-1d36-1802-00 Feb 18 10:41:21 2023 Auto(C)
3264-2e30-3130-322d-
566c-616e-3130
192.168.6.1 0262-1d3b-7403-00 Feb 18 10:41:17 2023 Auto(C)
192.168.7.2 0262-1d41-8304-00 Feb 18 10:41:41 2023 Auto(C)
# Use the display dhcp server ip-in-use command to view the assignable IP addresses in DHCP address pools.
[Switch] display dhcp server free-ip
Pool name: 5
Network: 192.168.5.0 mask 255.255.255.0
IP ranges from 192.168.5.2 to 192.168.5.99
IP ranges from 192.168.5.101 to 192.168.5.254
Pool name: 6
Network: 192.168.6.0 mask 255.255.255.0
IP ranges from 192.168.6.2 to 192.168.6.99
IP ranges from 192.168.6.101 to 192.168.6.254
Pool name: 7
Network: 192.168.7.0 mask 255.255.255.0
IP ranges from 192.168.7.2 to 192.168.7.99
IP ranges from 192.168.7.101 to 192.168.7.254
# Use the display dhcp server expired command to view expired IP address bindings. You can use the expired command to set the lease duration in an IP pool. The default lease duration in an IP pool is one day.
[Switch] display dhcp server expired
IP address Client-identifier/Hardware address Lease expiration
192.168.7.1 0262-1d36-2703-00 Feb 17 10:53:52 2023
3. Clear IP address bindings on the DHCP server.
# Use the reset dhcp server ip-in-use command in user view to clear both formal IP address bindings and temporary IP address bindings.
[Switch] quit
<Switch> reset dhcp server ip-in-use
# Use the display dhcp server ip-in-use command to view the IP addresses assigned by the DHCP server. The command output does not display any addresses.
<Switch> display dhcp server ip-in-use
IP address Client-identifier/ Lease expiration Type
Hardware address
# Use the reset dhcp server expired command in user view to clear expired IP address bindings.
<Switch> reset dhcp server expired
# Use the display dhcp server expired command to view expired IP address bindings. The command output does not display any address bindings.
<Switch> display dhcp server ip-in-use
IP address Client-identifier/ Lease expiration Type
Hardware address
4. View and clear IP address statistics and DHCP packet statistics on the DHCP server.
# Use the display dhcp server statistics command to view IP address statistics and DHCP packet statistics on the DHCP server.
<Switch> dis dhcp server statistics
Pool number: 3
Pool utilization: 0.00%
Bindings:
Automatic: 0
Manual: 0
Expired: 3
Conflict: 0
Messages received: 170
DHCPDISCOVER: 57
DHCPREQUEST: 57
DHCPDECLINE: 0
DHCPRELEASE: 56
DHCPINFORM: 0
BOOTPREQUEST: 0
Messages sent: 114
DHCPOFFER: 57
DHCPACK: 57
DHCPNAK: 0
BOOTPREPLY: 0
Bad Messages: 0
# Use the reset dhcp server statistics command in user view to clear IP address statistics and DHCP packet statistics on the DHCP server.
<Switch> reset dhcp server statistics
# Use the display dhcp server statistics command to view IP address statistics and DHCP packet statistics on the DHCP server again. The command output does not display any IP address statistics or DHCP packet statistics.
<Switch> dis dhcp server statistics
Pool number: 3
Pool utilization: 0.39%
Bindings:
Automatic: 3
Manual: 0
Expired: 0
Conflict: 0
Messages received: 0
DHCPDISCOVER: 0
DHCPREQUEST: 0
DHCPDECLINE: 0
DHCPRELEASE: 0
DHCPINFORM: 0
BOOTPREQUEST: 0
Messages sent: 0
DHCPOFFER: 0
DHCPACK: 0
DHCPNAK: 0
BOOTPREPLY: 0
Bad Messages: 0
Configuration files
#
dhcp enable
dhcp server forbidden-ip 192.168.5.100
dhcp server forbidden-ip 192.168.6.100
dhcp server forbidden-ip 192.168.7.100
#
vlan 5 to 7
#
dhcp server ip-pool 5
gateway-list 192.168.5.254
network 192.168.5.0 mask 255.255.255.0
dns-list 192.168.5.100
#
dhcp server ip-pool 6
gateway-list 192.168.6.254
network 192.168.6.0 mask 255.255.255.0
dns-list 192.168.6.100
#
dhcp server ip-pool 7
gateway-list 192.168.7.254
network 192.168.7.0 mask 255.255.255.0
dns-list 192.168.7.100
#
interface Vlan-interface5
ip address 192.168.5.254 255.255.255.0
dhcp select server
#
interface Vlan-interface6
ip address 192.168.6.254 255.255.255.0
dhcp select server
#
interface Vlan-interface7
ip address 192.168.7.254 255.255.255.0
dhcp select server
#
interface GigabitEthernet1/0/5
port link-mode bridge
port access vlan 5
#
interface GigabitEthernet1/0/6
port link-mode bridge
port access vlan 6
#
interface GigabitEthernet1/0/7
port link-mode bridge
port access vlan 7
#
Related documentation
· DHCP configuration in the Layer 3 IP services configuration guide for the device.
· DHCP commands in the Layer 3 IP services command reference for the device.
Configuring DHCP relay agent
Introduction
The following example describes the basic procedure to configure an interface as a DHCP relay agent. The DHCP relay agent enables clients to obtain IP addresses and configuration parameters from a DHCP server on another subnet.
Network configuration
As shown in Figure 2, the DHCP clients run on subnets 10.10.1.0/24 and the DHCP server IP address is 10.1.1.1/24. The DHCP server and the hosts run on different subnets and Switch A acts as the DHCP relay agent for clients. These clients can request IP addresses in subnet 10.10.1.0/24 and other network settings from the DHCP server via Switch A.
The client-facing port of Switch A is VLAN-interface 10 and the IP address of VLAN-interface 10 is 10.10.1.1/24. The server-facing port of Switch A is VLAN-interface 20 and the IP address of VLAN-interface 10 is 10.1.1.2/24.
Procedure
1. Configure Switch B, which acts as the DHCP server.
# Create VLAN-interface 20, and then assign IP address 10.1.1.1/24 to the interface.
<SwitchB> system-view
[SwitchB] vlan 20
[SwitchB-vlan20] port gigabitEthernet 1/0/1
[SwitchB-vlan20] quit
[SwitchB] interface vlan-interface 20
[SwitchB-Vlan-interface20] ip address 10.1.1.1 255.255.255.0
[SwitchB-Vlan-interface20] quit
# Create IP address pool 5, which assigns IP address to DHCP clients on subnet 10.10.1.0/24.
[SwitchB] dhcp server ip-pool 5
[SwitchB-dhcp-pool-5] network 10.10.1.0 mask 255.255.255.0
[SwitchB-dhcp-pool-5] dns-list 10.10.1.100
[SwitchB-dhcp-pool-5] gateway-list 10.10.1.1
[SwitchB-dhcp-pool-5] quit
# Configure a static route for connectivity to DHCP clients on subnet 10.10.1.0/24.
[SwitchB] ip route-static 10.10.1.0 24 10.1.1.2
# Enable the DHCP service.
[SwitchB] dhcp enable
# Enable VLAN-interface 20 to operate in DHCP server mode.
[SwitchB] interface vlan-interface 20
[SwitchB-Vlan-interface20] dhcp select server
[SwitchB-Vlan-interface20] quit
2. Configure Switch A, which acts as the DHCP relay agent.
# Create VLAN-interface 10 and VLAN-interface 20, and then assign IP address 10.10.1.1/24 to VLAN-interface 10 and IP address 10.1.1.2/24 to VLAN-interface 20.
<SwitchA> system-view
[SwitchA] vlan 10
[SwitchA-vlan10] port gigabitEthernet 1/0/1
[SwitchA-vlan10] quit
[SwitchA] vlan 20
[SwitchA-vlan20] port gigabitEthernet 1/0/2
[SwitchA-vlan20] quit
[SwitchA] interface vlan-interface 10
[SwitchA-Vlan-interface10] ip address 10.10.1.1 255.255.255.0
[SwitchA-Vlan-interface10] quit
[SwitchA] interface vlan-interface 20
[SwitchA-Vlan-interface20] ip address 10.1.1.2 255.255.255.0
[SwitchA-Vlan-interface20] quit
# Enable the DHCP service.
[SwitchA] dhcp enable
# # Enable VLAN-interface 10 to operate in DHCP relay agent mode.
[SwitchA] interface vlan-interface 10
[SwitchA-Vlan-interface10] dhcp select relay
# Specify DHCP server address 10.1.1.1 on VLAN-interface 10.
[SwitchA-Vlan-interface10] dhcp relay server-address 10.1.1.1
Verifying the configuration
Check whether the DHCP clients can obtain IP addresses and other network settings from the DHCP server via the DHCP relay agent.
# Use the display dhcp relay server-address command to view the DHCP server addresses specified on VLAN-interface 10.
[SwitchA] display dhcp relay server-address
Interface name Server IP address Public/VRF name Class name
Vlan10 10.1.1.1 Y/-- --
# Use the display dhcp server ip-in-use command to view the IP addresses assigned by the DHCP server.
[SwitchB] display dhcp server ip-in-use
IP address Client-identifier/ Lease expiration Type
Hardware address
10.10.1.2 0036-3232-352e-3261- Feb 18 16:14:25 2023 Auto(C)
3264-2e30-3130-322d-
566c-616e-3130
# Use the display dhcp relay statistics command to view DHCP packet statistics on the DHCP relay agent.
[SwitchB] display dhcp relay statistics
DHCP packets dropped: 0
Incorrect Message type: 0
Option Parsing failed: 0
Mac-check failed: 0
Other count: 0
DHCP packets received from clients: 2
DHCPDISCOVER: 1
DHCPREQUEST: 1
DHCPINFORM: 0
DHCPRELEASE: 0
DHCPDECLINE: 0
BOOTPREQUEST: 0
DHCP packets received from servers: 2
DHCPOFFER: 1
DHCPACK: 1
DHCPNAK: 0
BOOTPREPLY: 0
DHCP packets relayed to servers: 2
DHCPDISCOVER: 1
DHCPREQUEST: 1
DHCPINFORM: 0
DHCPRELEASE: 0
DHCPDECLINE: 0
BOOTPREQUEST: 0
DHCP packets relayed to clients: 2
DHCPOFFER: 1
DHCPACK: 1
DHCPNAK: 0
BOOTPREPLY: 0
DHCP packets sent to servers: 0
DHCPDISCOVER: 0
DHCPREQUEST: 0
DHCPINFORM: 0
DHCPRELEASE: 0
DHCPDECLINE: 0
BOOTPREQUEST: 0
DHCP packets sent to clients: 0
DHCPOFFER: 0
DHCPACK: 0
DHCPNAK: 0
BOOTPREPLY: 0
# Use the reset dhcp relay statistics command in user view to clear DHCP packet statistics on the DHCP relay agent.
[SwitchB] quit
<SwitchB> reset dhcp relay statistics
# Use the display dhcp relay statistics command to view DHCP packet statistics on the DHCP relay agent again. The command output does not display any DHCP packet statistics.
[SwitchB] display dhcp relay statistics
DHCP packets dropped: 0
Incorrect Message type: 0
Option Parsing failed: 0
Mac-check failed: 0
Other count: 0
DHCP packets received from clients: 0
DHCPDISCOVER: 0
DHCPREQUEST: 0
DHCPINFORM: 0
DHCPRELEASE: 0
DHCPDECLINE: 0
BOOTPREQUEST: 0
DHCP packets received from servers: 0
DHCPOFFER: 0
DHCPACK: 0
DHCPNAK: 0
BOOTPREPLY: 0
DHCP packets relayed to servers: 0
DHCPDISCOVER: 0
DHCPREQUEST: 0
DHCPINFORM: 0
DHCPRELEASE: 0
DHCPDECLINE: 0
BOOTPREQUEST: 0
DHCP packets relayed to clients: 0
DHCPOFFER: 0
DHCPACK: 0
DHCPNAK: 0
BOOTPREPLY: 0
DHCP packets sent to servers: 0
DHCPDISCOVER: 0
DHCPREQUEST: 0
DHCPINFORM: 0
DHCPRELEASE: 0
DHCPDECLINE: 0
BOOTPREQUEST: 0
DHCP packets sent to clients: 0
DHCPOFFER: 0
DHCPACK: 0
DHCPNAK: 0
BOOTPREPLY: 0
Configuration files
· Switch B:
dhcp enable
#
vlan 20
#
dhcp server ip-pool 5
gateway-list 10.10.1.1
network 10.10.1.0 mask 255.255.255.0
dns-list 10.10.1.100
#
interface Vlan-interface20
ip address 10.1.1.1 255.255.255.0
dhcp select server
#
interface GigabitEthernet1/0/1
port link-mode bridge
port access vlan 20
#
ip route-static 10.10.1.0 24 10.1.1.2
#
· Switch A:
#
dhcp enable
#
vlan 10
#
vlan 20
#
interface Vlan-interface10
ip address 10.10.1.1 255.255.255.0
dhcp select relay
dhcp relay server-address 10.1.1.1
#
interface Vlan-interface20
ip address 10.1.1.2 255.255.255.0
#
interface GigabitEthernet1/0/1
port link-mode bridge
port access vlan 10
#
interface GigabitEthernet1/0/2
port link-mode bridge
port access vlan 20
#
Related documentation
· DHCP configuration in the Layer 3 IP services configuration guide for the device.
· DHCP commands in the Layer 3 IP services command reference for the device.
Configuring DHCP snooping
Introduction
The following example describes the basic procedure to configure DHCP snooping.
Network configuration
As shown in Figure 3, the switch is connected to the authorized DHCP server through GigabitEthernet 1/0/1, to the unauthorized DHCP server through GigabitEthernet 1/0/3, and to the DHCP client through GigabitEthernet 1/0/2. Configure the network to meet the following requirements:
· Only the port connected to the authorized DHCP server can forward the responses from the DHCP server.
· The DHCP snooping device records clients' IP-to-MAC bindings by reading DHCP-ACK messages received from the trusted port and the DHCPREQUEST messages.
Procedure
# Enable global DHCP snooping.
<Switch> system-view
[Switch] dhcp snooping enable
# Configure GigabitEthernet 1/0/1 as a trusted port.
[Switch] interface gigabitethernet 1/0/1
[Switch-GigabitEthernet1/0/1] dhcp snooping trust
[Switch-GigabitEthernet1/0/1] quit
# Enable recording clients' IP-to-MAC bindings on GigabitEthernet 1/0/2.
[Switch] interface gigabitethernet 1/0/2
[Switch-GigabitEthernet1/0/2] dhcp snooping binding record
[Switch-GigabitEthernet1/0/2] quit
Verifying the configuration
Verify that the DHCP client can obtain an IP address and other configuration parameters only from the authorized DHCP server. (Details not shown.)
· To check the DHCP snooping entry recorded for the client, use the display dhcp snooping binding command.
· To clear DHCP snooping entries, use the reset dhcp snooping binding command in user view.
Configuration files
#
dhcp snooping enable
#
interface GigabitEthernet1/0/1
port link-mode bridge
dhcp snooping trust
#
interface GigabitEthernet1/0/2
port link-mode bridge
dhcp snooping binding record
#
Related documentation
· DHCP configuration in the Layer 3 IP services configuration guide for the device.
· DHCP commands in the Layer 3 IP services command reference for the device.
Configuring dynamic IPv6 address assignment
Introduction
The following example describes the basic procedure to configure an interface as a DHCPv6 server for dynamic IPv6 address assignment.
Network configuration
As shown in Figure 4, Switch A and Switch B are gateway devices for internal hosts. Configure the network to meet the following requirements:
· Switch A and Switch B are connected through Ethernet interfaces. The interfaces of each switch operate in different VLAN and have IPv6 addresses.
· VLAN-interface 3 operate in DHCPv6 server mode to assign IPv6 addresses to hosts.
· Switch A and Switch B have IPv6 static routes to ensure network connectivity.
Procedure
1. Configure Switch A.
# Create VLAN 3 and assign GigabitEthernet 1/0/2 to VLAN 3.
<SwitchA> system-view
[SwitchA] vlan 3
[SwitchA-vlan3] port gigabitethernet 1/0/2
[SwitchA-vlan3] quit
# Create VLAN 2 and assign GigabitEthernet 1/0/1 to VLAN 2.
[SwitchA] vlan 2
[SwitchA-vlan2] port gigabitethernet 1/0/1
[SwitchA-vlan2] quit
# Specify an IPv6 global unicast address for VLAN-interface 2.
[SwitchA] interface vlan-interface 2
[SwitchA-Vlan-interface2] ipv6 address 3001::1/64
[SwitchA-Vlan-interface2] quit
# Specify an IPv6 global unicast address for VLAN-interface 3 and disable RA message suppression on VLAN-interface 1.
[SwitchA] interface vlan-interface 3
[SwitchA-Vlan-interface3] ipv6 address 2001::1/64
[SwitchA-Vlan-interface3] undo ipv6 nd ra halt
# Apply an IPv6 address pool to VLAN-interface 3.
[SwitchA-Vlan-interface3] ipv6 dhcp server apply pool 1 allow-hint rapid-commit
# Set the M flag to 1 in RA advertisements to be sent on VLAN-interface 3. Hosts that receive the RA advertisements will obtain IPv6 addresses through DHCPv6.
[SwitchA-Vlan-interface3] ipv6 nd autoconfig managed-address-flag
# Set the O flag to 1 in RA advertisements to be sent on VLAN-interface 3. Hosts that receive the RA advertisements will obtain configuration information other than IPv6 address through DHCPv6.
[SwitchA-Vlan-interface3] ipv6 nd autoconfig other-flag
# Configure VLAN-interface 3 to operate in DHCPv6 server mode.
[SwitchA-Vlan-interface3] ipv6 dhcp select server
[SwitchA-Vlan-interface3] quit
# Create IPv6 address pool 1.
[SwitchA] ipv6 dhcp pool 1
[SwitchA-dhcp6-pool-1] network 2001::/64
[SwitchA-dhcp6-pool-1] dns-server 1::1
[SwitchA-dhcp6-pool-1] quit
# Configure an IPv6 static route destined for 4001::/64 and the next hop of the route is 3001::2.
[SwitchA] ipv6 route-static 4001:: 64 3001::2
# Save the configuration.
[SwitchA] save force
# Create VLAN 2 and assign GigabitEthernet 1/0/1 to VLAN 2.
<SwitchB> system-view
[SwitchB] vlan 2
[SwitchB-vlan2] port gigabitethernet 1/0/1
[SwitchB-vlan2] quit
# Create VLAN 3 and assign GigabitEthernet 1/0/2 to VLAN 3.
[SwitchB] vlan 3
[SwitchB-vlan3] port gigabitethernet 1/0/2
[SwitchB-vlan3] quit
# Specify an IPv6 global unicast address for VLAN-interface 2.
[SwitchB] interface vlan-interface 2
[SwitchB-Vlan-interface2] ipv6 address 3001::2/64
[SwitchB-Vlan-interface2] quit
# Specify an IPv6 global unicast address for VLAN-interface 3 and disable RA message suppression on VLAN-interface 3.
[SwitchB] interface vlan-interface 3
[SwitchB-Vlan-interface3] ipv6 address 4001::1/64
[SwitchB-Vlan-interface3] undo ipv6 nd ra halt
# Apply an IPv6 address pool to VLAN-interface 3.
[SwitchB-Vlan-interface3] ipv6 dhcp server apply pool 1 allow-hint rapid-commit
# Set the M flag to 1 in RA advertisements to be sent on VLAN-interface 3. Hosts that receive the RA advertisements will obtain IPv6 addresses through DHCPv6.
[SwitchB-Vlan-interface3] ipv6 nd autoconfig managed-address-flag
# Set the O flag to 1 in RA advertisements to be sent on VLAN-interface 3. Hosts that receive the RA advertisements will obtain configuration information other than IPv6 address through DHCPv6.
[SwitchB-Vlan-interface3] ipv6 nd autoconfig other-flag
# Configure VLAN-interface 3 to operate in DHCPv6 server mode.
[SwitchB-Vlan-interface3] ipv6 dhcp select server
[SwitchB-Vlan-interface3] quit
# Create IPv6 address pool 1.
[SwitchB] ipv6 dhcp pool 1
[SwitchB-dhcp6-pool-1] network 4001::/64
[SwitchB-dhcp6-pool-1] dns-server 1::1
[SwitchB-dhcp6-pool-1] quit
# Configure an IPv6 static route destined for 2001::/64 and the next hop of the route is 3001::1.
[SwitchB] ipv6 route-static 2001:: 64 3001::1
# Save the configuration.
[SwitchB] save force
3. Configure Host A.
Configure IPv6 on Host A, and then enable Host A to use DHCPv6 for IPv6 address acquisition.
4. Configure Host B.
Configure IPv6 on Host B, and then enable Host B to use DHCPv6 for IPv6 address acquisition.
Verifying the configuration
1. View the DHCPv6 server configuration.
# View DHCPv6 address pool information.
[SwitchA] display ipv6 dhcp server ip-in-use
DHCPv6 pool: 1
Network: 2001::/64
Preferred lifetime 604800 seconds, valid lifetime 2592000 seconds
DNS server addresses:
1::1
IP-in-use threshold: 100
PD-in-use threshold: 100
# View DHCPv6 server configuration information on VLAN-interface 3.
[SwitchA] display ipv6 dhcp server
Interface Pool
Vlan-interface3 1
2. View and clear IP address bindings on the DHCP server.
# View the IPv6 addresses assigned by the DHCPv6 server on Switch A.
[SwitchA] display ipv6 dhcp server ip-in-use
Pool: 1
IPv6 address Type Lease expiration
2001::2 Auto(C) Sep 30 11:45:07 2021
# View information about the neighbors of GigabitEthernet 1/0/2 on Switch A.
[SwitchA] display ipv6 neighbors interface gigabitethernet 1/0/2
Type: S-Static D-Dynamic O-Openflow R-Rule IS-Invalid static
IPv6 address MAC address VLAN/VSI Interface State T Aging
2001::2 b025-0b54-0106 -- GE1/0/2 REACH D 29
FE80::B225:BFF:FE54:106 b025-0b54-0106 -- GE1/0/2 REACH D 18
The output shows that Host A has obtained IPv6 global unicast address 2001::2.
# View expired IPv6 address bindings.
[SwitchA] display ipv6 dhcp server expired
IPv6 address DUID Lease expiration
2001::3 0262-9ead-ab03-00 Feb 17 17:09:02 2023
# Clear both formal IPv6 address bindings and temporary IPv6 address bindings. Then, view the IPv6 addresses assigned by the DHCPv6 server again. The command output does not display any IPv6 address bindings.
[SwitchA] quit
<SwitchA> reset ipv6 dhcp server ip-in-use
<SwitchA> display ipv6 dhcp server ip-in-use
# Clear expired IPv6 address bindings. Then, view expired IPv6 address bindings on the DHCPv6 server again. The command output does not display any expired IPv6 address bindings.
<SwitchA> reset ipv6 dhcp server expired
<SwitchA> display ipv6 dhcp server expired
IPv6 address DUID Lease expiration
3. View and clear DHCPv6 packet statistics on the DHCPv6 server.
# View DHCPv6 packet statistics on the DHCPv6 server.
<SwitchA> display ipv6 dhcp server statistics
Bindings:
Ip-in-use : 0
Pd-in-use : 0
Expired : 1
Conflict : 1
Packets received : 24
Solicit : 8
Request : 8
Confirm : 0
Renew : 0
Rebind : 0
Release : 8
Decline : 0
Information-request : 0
Relay-forward : 0
Packets dropped : 0
Packets sent : 24
Advertise : 8
Reconfigure : 0
Reply : 16
Relay-reply : 0
# To clear DHCPv6 packet statistics on the DHCPv6 server, use the reset ipv6 dhcp server statistics command in user view.
<SwitchA> reset ipv6 dhcp server statistics
<SwitchA> display ipv6 dhcp server statistics
Bindings:
Ip-in-use : 0
Pd-in-use : 0
Expired : 1
Conflict : 1
Packets received : 0
Solicit : 0
Request : 0
Confirm : 0
Renew : 0
Rebind : 0
Release : 0
Decline : 0
Information-request : 0
Relay-forward : 0
Packets dropped : 0
Packets sent : 0
Advertise : 0
Reconfigure : 0
Reply : 0
Relay-reply : 0
# View the IPv6 addresses assigned by the DHCPv6 server on Switch B.
[SwitchB] display ipv6 dhcp server ip-in-use
Pool: 1
IPv6 address Type Lease expiration
4001::2 Auto(C) Sep 30 14:05:49 2021
# View information about the neighbors of GigabitEthernet 1/0/2 on Switch B.
[SwitchB] display ipv6 neighbors interface gigabitethernet 1/0/2
Type: S-Static D-Dynamic O-Openflow R-Rule IS-Invalid static
IPv6 address MAC address VLAN/VSI Interface State T Aging
4001::2 b043-5415-0406 -- GE1/0/2 REACH D 3
FE80::B243:54FF:FE15:406 b043-5415-0406 -- GE1/0/2 REACH D 44
The output shows that Host B has obtained IPv6 global unicast address 4001::2.
# Check whether Host A and Host B can ping each other successfully.
Configuration files
· Switch A:
#
vlan 2 to 3
#
ipv6 dhcp pool 1
network 2001::/64
dns-server 1::1
#
interface Vlan-interface3
ipv6 dhcp select server
ipv6 dhcp server apply pool 1 allow-hint rapid-commit
ipv6 address 2001::1/64
ipv6 nd autoconfig managed-address-flag
ipv6 nd autoconfig other-flag
undo ipv6 nd ra halt
#
interface Vlan-interface2
ipv6 address 3001::1/64
#
interface GigabitEthernet1/0/1
port link-mode bridge
#
interface GigabitEthernet1/0/2
port link-mode bridge
port access vlan 3
#
ipv6 route-static 4001:: 64 3001::2
#
· Switch B:
#
vlan 2 to 3
#
ipv6 dhcp pool 1
network 4001::/64
dns-server 1::1
#
interface Vlan-interface2
ipv6 address 3001::2/64
#
interface Vlan-interface3
ipv6 dhcp select server
ipv6 dhcp server apply pool 1 allow-hint rapid-commit
ipv6 address 4001::1/64
ipv6 nd autoconfig managed-address-flag
ipv6 nd autoconfig other-flag
undo ipv6 nd ra halt
#
interface GigabitEthernet1/0/1
port link-mode bridge
port access vlan 2
#
interface GigabitEthernet1/0/2
port link-mode bridge
port access vlan 3
#
ipv6 route-static 2001:: 64 3001::1
#
Related documentation
· DHCPv6 configuration in the Layer 3 IP services configuration guide for the device.
· DHCPv6 commands in the Layer 3 IP services command reference for the device.