Example: Configuring DHCP server selection

Network configuration

As shown in Figure 26, the DHCP client and the DHCP servers are in different subnets. DHCP server 1 and DHCP server 2 both have a DHCP address pool that contains IP addresses in subnet 22.22.22.0/24, but neither has DHCP enabled.

Configure the DHCP relay agent for the DHCP client to obtain an IP address in subnet 22.22.22.0/24 and other configuration parameters from a DHCP server. The DHCP relay agent is connected to the DHCP client through VLAN-interface 2, to DHCP server 1 through VLAN-interface 3, and to DHCP server 2 through VLAN-interface 4.

Figure 26: Network diagram

Procedure

  1. Assign IP addresses to interfaces on the switches. (Details not shown.)

  2. Configure Switch B and Switch C as DHCP servers. (Details not shown.)

  3. Configure the DHCP relay agent on Switch A:

    # Enable DHCP.

    <SwitchA> system-view
    [SwitchA] dhcp enable
    

    # Enable the DHCP relay agent on VLAN-interface 2.

    [SwitchA] interface vlan-interface 2
    [SwitchA-Vlan-interface2] dhcp select relay
    

    # Specify the IP addresses of the DHCP servers.

    [SwitchA-Vlan-interface2] dhcp relay server-address 1.1.1.1
    [SwitchA-Vlan-interface2] dhcp relay server-address 2.2.2.2
    

    # Specify the DHCP server selecting algorithm as master-backup.

    [SwitchA-Vlan-interface2] dhcp relay server-address algorithm master-backup
    

    # Configure the DHCP relay agent to switch back to the master DHCP server 3 minutes after it switches to the backup DHCP server.

    [SwitchA-Vlan-interface2] dhcp relay master-server switch-delay 3
    

Verifying the configuration

# Verify that the DHCP client cannot obtain an IP address and that the following log is output in about 30 seconds.

DHCPR/3/DHCPR_SERVERCHANGE: -MDC=1;
 Switched to the server at 2.2.2.2 because the current server did not respond.

# Enable DHCP on the DHCP server at 1.1.1.1. (Details not shown.)

# Verify that the DHCP client cannot obtain an IP address and that the following log is output in about 3 minutes.

DHCPR/3/DHCPR_SWITCHMASTER: -MDC=1;
 Switched to the master DHCP server at 1.1.1.1.

# Verify that the DHCP client obtains an IP address. (Details not shown.)