Example: Customizing DHCP option

Network configuration

As shown in Figure 22, DHCP clients obtain IP addresses and PXE server addresses from the DHCP server (Switch A). The subnet for address allocation is 10.1.1.0/24.

Configure the address allocation scheme as follows:

Assign PXE addresses

To clients

2.3.4.5 and 3.3.3.3

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

1.2.3.4 and 2.2.2.2.

Other clients.

The DHCP server assigns PXE server addresses to DHCP clients through Option 43, a customized option. The format of Option 43 and that of the PXE server address sub-option are shown in Figure 14 and Figure 16. For example, the value of Option 43 configured in the DHCP address pool is 80 0B 00 00 02 01 02 03 04 02 02 02 02.

Figure 22: Network diagram

Procedure

  1. Specify IP addresses for the interfaces. (Details not shown.)

  2. Configure the DHCP server:

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

    <SwitchA> system-view
    [SwitchA] dhcp class ss
    [SwitchA-dhcp-class-ss] if-match rule 1 hardware-address aabb-aabb-0000 mask ffff-ffff-0000
    [SwitchA-dhcp-class-ss] quit
    

    # Create DHCP option group 1 and customize Option 43.

    [SwitchA] dhcp option-group 1
    [SwitchA-dhcp-option-group-1] option 43 hex 800B0000020203040503030303
    

    # Enable the DHCP server on VLAN-interface 2.

    [SwitchA] interface vlan-interface 2
    [SwitchA-Vlan-interface2] dhcp select server
    [SwitchA-Vlan-interface2] quit
    

    # Create DHCP address pool 0.

    [SwitchA] dhcp server ip-pool 0
    

    # Specify the subnet for dynamic address allocation.

    [SwitchA-dhcp-pool-0] network 10.1.1.0 mask 255.255.255.0
    

    # Customize Option 43.

    [SwitchA-dhcp-pool-0] option 43 hex 800B0000020102030402020202
    

    # Associate DHCP user class ss with option group 1.

    [SwitchA-dhcp-pool-0] class ss option-group 1
    [SwitchA-dhcp-pool-0] quit
    

    # Enable DHCP.

    [SwitchA] dhcp enable
    

Verifying the configuration

# Verify that Switch B can obtain an IP address on subnet 10.1.1.0/24 and the corresponding PXE server addresses from the Switch A. (Details not shown.)

# On the DHCP server, display the IP addresses assigned to the clients.

[SwitchA] display dhcp server ip-in-use
IP address       Client identifier/    Lease expiration      Type
                 Hardware address
10.1.1.2         aabb-aabb-ab01        Jan 14 22:25:03 2015  Auto(C)