Example: Configuring DHCP server selection

Network configuration

As shown in Figure 28, 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 28: Network diagram

Procedure


[IMPORTANT: ]

IMPORTANT:

By default, interfaces on the device are disabled (in ADM or Administratively Down state). To have an interface operate, you must use the undo shutdown command to enable that interface.


  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.)