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:
If only the option-code argument is specified in the rule, packets containing the option match the rule.
If the option-code and hex-string arguments are specified in the rule, packets that have the specified hexadecimal string in the specified option match the rule.
If the option-code, hex-string, offset and length arguments are specified in the rule, packets match the rule as long as their content from offset+1 bit to offset+length bit in the specified option is the same as the specified hexadecimal string.
If the option-code, hex-string, and mask arguments are specified in the rule, the DHCP server ANDs the content from the first bit to the mask-1 bit in the specified option with the mask. Then the server compares the result with the result of the AND operation between hex-string and mask. If the two results are the same, the received packet matches the rule.
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