Example: Configuring DHCP user class

Network requirement

As shown in Figure 19, the DHCP relay agent (Switch A) forwards DHCP packets between DHCP clients and the DHCP server (Switch B). Enable switch A to support Option 82 so that switch A can add Option 82 in the DHCP requests sent by the DHCP clients.

Configure the address allocation scheme as follows:

Assign IP addresses

To clients

10.10.1.2 to 10.10.1.10

The DHCP request contains Option 82.

10.10.1.11 to 10.10.1.26

The hardware address in the request is six bytes long and begins with aabb-aabb-aab.

For clients on subnet 10.10.1.0/24, the DNS server address is 10.10.1.20/24 and the gateway address is 10.10.1.254/24.

Figure 19: Network diagram

Procedure

  1. Specify IP addresses for interfaces on the DHCP server and the DHCP relay agent. (Details not shown.)

  2. Configure DHCP services:

    # Create DHCP user class tt and configure a match rule to match client requests with Option 82.

    <SwitchB> system-view
    [SwitchB] dhcp class tt
    [SwitchB-dhcp-class-tt] if-match rule 1 option 82
    [SwitchB-dhcp-class-tt] quit
    

    # Create DHCP user class ss and configure a match rule to match DHCP requests in which the hardware address is six bytes long and begins with aabb-aabb-aab.

    [SwitchB] dhcp class ss
    [SwitchB-dhcp-class-ss] if-match rule 1 hardware-address aabb-aabb-aab0 mask ffff-ffff-fff0
    [SwitchB-dhcp-class-ss] quit
    

    # Create DHCP address pool aa.

    [SwitchB] dhcp server ip-pool aa
    

    # Specify the subnet for dynamic allocation.

    [SwitchB-dhcp-pool-aa] network 10.10.1.0 mask 255.255.255.0
    

    # Specify the address range for dynamic allocation.

    [SwitchB-dhcp-pool-aa] address range 10.10.1.2 10.10.1.100
    

    # Specify the address range for user class tt.

    [SwitchB-dhcp-pool-aa] class tt range 10.10.1.2 10.10.1.10
    

    # Specify the address range for user class ss.

    [SwitchB-dhcp-pool-aa] class ss range 10.10.1.11 10.10.1.26
    

    # Specify the gateway address and the DNS server address.

    [SwitchB-dhcp-pool-aa] gateway-list 10.10.1.254
    [SwitchB-dhcp-pool-aa] dns-list 10.10.1.20
    [SwitchB-dhcp-pool-aa] quit
    

    # Enable DHCP and configure the DHCP server to handle Option 82.

    [SwitchB] dhcp enable
    [SwitchB] dhcp server relay information enable
    

    # Enable DHCP server on VLAN-interface10.

    [SwitchB] interface vlan-interface 10
    [SwitchB-Vlan-interface10] dhcp select server
    [SwitchB-Vlan-interface10] quit
    

Verifying the configuration

# Verify that clients matching the user classes can obtain IP addresses in the specified ranges and all other configuration parameters from the DHCP server. (Details not shown.)

# Display the IP address 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        0031-3865-392e-6262-  Jan 14 22:25:03 2015  Auto(C)
                 3363-2e30-3230-352d-
                 4745-302f-30
10.10.1.11       aabb-aabb-aab1        Jan 14 22:25:03 2015  Auto(C)