As shown in Figure 1, the DHCP server (Switch A) dynamically assigns IP addresses to clients in the LAN.
Configure two subnets in the address pool on the DHCP server: 10.1.xx.0/24 as the primary subnet and 10.xx.2.0/24 as the secondary subnet. The DHCP server selects IP addresses from the secondary subnet when the primary subnet has no assignable addresses.
Switch A assigns the following parameters:
· The default gateway 10.1.xx.254/24 to clients on subnet 10.1.xx.0/24.
· The default gateway 10.xx.2.254/24 to clients on subnet 10.xx.2.0/24.
# Enable DHCP.
[SwitchA] dhcp enable
# Configure the primary and secondary IP addresses of VLAN-interface 10.
[SwitchA] interface vlan-interface 10
[SwitchA-Vlan-interface10] ip address 10.1.xx.1 24
[SwitchA-Vlan-interface10] ip address 10.xx.2.1 24 sub
# Enable the DHCP server on VLAN-interface 10.
[SwitchA-Vlan-interface10] dhcp select server
[SwitchA-Vlan-interface10] quit
# Create DHCP address pool aa.
[SwitchA] dhcp server ip-pool aa
# Specify the primary subnet and the gateway address for dynamic allocation.
[SwitchA-dhcp-pool-aa] network 10.1.xx.0 mask 255.255.255.0
[SwitchA-dhcp-pool-aa] gateway-list 10.1.xx.254
# Specify the secondary subnet and the gateway address for dynamic allocation.
[SwitchA-dhcp-pool-aa] network 10.xx.2.0 mask 255.255.255.0 secondary
[SwitchA-dhcp-pool-aa-secondary] gateway-list 10.xx.2.254
[SwitchA-dhcp-pool-aa-secondary] quit
[SwitchA-dhcp-pool-aa] quit
# Verify that the DHCP server assigns clients IP addresses and gateway address from the secondary subnet when no address is available from the primary subnet. (Details not shown.)
# Display the primary and secondary subnet IP addresses the DHCP server has assigned. The following is part of the command output.
[SwitchA] display dhcp server ip-in-use
IP address Client identifier/ Lease expiration Type
Hardware address
10.1.xx.2 0031-3865-392e-6262- Jan 14 22:25:03 2015 Auto(C)
3363-2e30-3230-352d-
4745-302f-30
10.xx.2.2 3030-3030-2e30-3030- Jan 14 22:25:03 2015 Auto(C)
662e-3030-3033-2d45-
7568-6572-1e
Specify a primary subnet and multiple secondary subnets in an address pool.
The DHCP server selects an IP address from the primary subnet first. If there is no assignable IP address on the primary subnet, the DHCP server selects an IP address from secondary subnets in the order they are configured.