68
Configure two subnets in the address pool on the DHCP server: 10.1.1.0/24 as the primary subnet
and 10.1.2.0/24 as the secondary subnet. The DHCP server selects an IP address from the
secondary subnet when the primary subnet has no assignable addresses.
Router A assigns the following parameters:
• The default gateway 10.1.1.254/24 to clients on subnet 10.1.1.0/24.
• The default gateway 10.1.2.254/24 to clients on subnet 10.1.2.0/24.
Figure 28 Network diagram
Configuration procedure
# Enable DHCP.
<RouterA> system-view
[RouterA] dhcp enable
# Configure the primary and secondary IP addresses of interface GigabitEthernet1/0/1, and enable
the DHCP server on GigabitEthernet 1/0/1.
[RouterA] interface gigabitethernet 1/0/1
[RouterA-GigabitEthernet1/0/1] ip address 10.1.1.1 24
[RouterA-GigabitEthernet1/0/1] ip address 10.1.2.1 24 sub
[RouterA-GigabitEthernet1/0/1] dhcp select server
[RouterA-GigabitEthernet1/0/1] quit
# Create DHCP address pool aa.
[RouterA] dhcp server ip-pool aa
# Specify the primary subnet and the gateway for dynamic allocation.
[RouterA-dhcp-pool-aa] network 10.1.1.0 mask 255.255.255.0
[RouterA-dhcp-pool-aa] gateway-list 10.1.1.254
# Specify the secondary subnet and the gateway for dynamic allocation.
[RouterA-dhcp-pool-aa] network 10.1.2.0 mask 255.255.255.0 secondary
[RouterA-dhcp-pool-aa-secondary] gateway-list 10.1.2.254
[RouterA-dhcp-pool-aa-secondary] quit
[RouterA-dhcp-pool-aa] quit
Verifying the configuration
# Verify that the DHCP server assigns clients IP addresses and gateway address from the secondary
subnet when no assignable address is available from the primary subnet. (Details not shown.)
# On the DHCP server, display IP addresses assigned to the clients. The following is part of the
command output.
[RouterA] display dhcp server ip-in-use
...
GatewayDHCP client DHCP client DHCP client
Router A
DHCP server
GE1/0/1
10.1.1.1/24
10.1.2.1/24 sub