if-match

Use if-match to configure a match rule for a DHCP user class.

Use undo if-match to remove the match rule for a DHCP user class.

Syntax

if-match rule rule-number option option-code [ hex hex-string [ mask mask | offset offset length length ] ]

undo if-match rule rule-number

Default

No match rule is configured for the DHCP user class.

Views

DHCP user class view

Predefined user roles

network-admin

Parameters

rule rule-number: Assigns the match rule an ID in the range of 1 to 16. A smaller ID represents a higher match priority.

option option-code: Matches a DHCP option by a number in the range of 1 to 254.

hex hex-string: Matches the specified hexadecimal string in the option. The length of the hexadecimal string must be an even number in the range of 2 to 256. If you do not specify this option, the DHCP server only checks whether the specified option exists in the received packets.

mask mask: Specifies the mask used to match the option content. The mask argument is a hexadecimal string, whose length is an even number in the range of 2 to 256. The length of mask must be the same as that of hex-string.

offset offset: Specifies the offset used to match the option, in the range of 0 to 254 bytes. If you do not specify this option, the server matches the entire option with the rule.

length length: Matches the specified length of the option, in the range of 1 to 128 bytes. The specified length must be the same as the hex-string length.

Usage guidelines

You can configure multiple match rules for a DHCP user class. Each match rule is uniquely identified by a rule ID. Different match rules can include the same option code, but they cannot have the same matching criteria.

The DHCP server compares DHCP requests against the match rules. A DHCP client matches a DHCP user class when its request matches one of the specified match rules.

The match operation follows these guidelines:

Examples

# Configure match rule 1 to match DHCP requests that contain Option 82 for DHCP user class exam.

<Sysname> system-view
[Sysname] dhcp class exam
[Sysname-dhcp-class-exam] if-match rule 1 option 82

# Configure match rule 2 to match DHCP requests that contain Option 82. Option 82's first three bytes are 0x13ae92 for the DHCP user class exam.

<Sysname> system-view
[Sysname] dhcp class exam
[Sysname-dhcp-class-exam] if-match rule 2 option 82 hex 13ae92 offset 0 length 3

# Configure match rule 3 to match DHCP requests that contain Option 82. Option 82's highest bit of the fourth byte is 1 for the DHCP user class exam.

<Sysname> system-view
[Sysname] dhcp class exam
[Sysname-dhcp-class-exam] if-match rule 3 option 82 hex 00000080 mask 00000080

Related commands

dhcp class