< Home

dhcp option82 format

Function

The dhcp option82 format command configures the format of the Option 82 field in a DHCP message.

The undo dhcp option82 format command restores the default format of the Option 82 field in a DHCP message.

By default, the Option 82 field in a DHCP message is in the format of default.

Format

dhcp option82 [ vlan vlan-id ] [ ce-vlan ce-vlan-id ] [ circuit-id | remote-id ] format { default | common | extend | user-defined text }

undo dhcp option82 [ vlan vlan-id ] [ ce-vlan ce-vlan-id ] [ circuit-id | remote-id ] format

Parameters

Parameter Description Value

circuit-id

Indicates the circuit ID (CID) in the Option 82 field. If the CID is not specified, the format of the Option 82 field is default.

-

remote-id

Indicates the remote ID (RID) in the Option 82 field. If the RID is not specified, the format of the Option 82 field is default.

-

default

Indicates the default format of the Option 82 field.

  • CID format: interface name:svlan.cvlan, host name/0/0/0/0/0, in ASCII format
  • RID format: device MAC address, in hexadecimal notation

-

common

Indicates the common format of the Option 82 field.

  • CID format: {eth|trunk}slot ID/subcard ID/port ID:svlan.cvlan host name0/0/0/0/0, in ASCII format
  • RID format: device MAC address (6 bytes), in ASCII format

-

extend

Indicates the extended format of the Option 82 field.

  • CID format: circuit-id type (0) + length (4) + S-VLAN ID (2 bytes) + slot ID (5 bits) + subslot ID (3 bits) + port (1 byte), in hexadecimal notation

  • RID format: remote-id type (0) + length (6) + device MAC address (6 bytes), in hexadecimal notation

In the CID and RID formats, the values without a unit are fixed values of the fields; the values with a unit indicate the field lengths.

-

user-defined text

Indicates the user-defined format of the Option 82 field.

The value is a string of 1 to 255 characters. For details, see the description in "Usage Guideline."

vlan vlan-id

Indicates an outer VLAN ID. If a VLAN ID is specified, only the format of the Option 82 field in the DHCP messages sent from the specified VLAN is configured. If no VLAN is specified, the format of the Option 82 field in all the DHCP messages received by the interface is configured.

The value is an integer that ranges from 1 to 4094.

ce-vlan ce-vlan-id

Indicates an inner VLAN ID.

The value is an integer that ranges from 1 to 4094.

Views

System view, Ethernet interface view, GE interface view, XGE interface view, 25GE interface view, MultiGE interface view, 40GE interface view, 100GE interface view, Eth-Trunk interface view, port group view

Default Level

2: Configuration level

Usage Guidelines

Usage Scenario

After the function of inserting the Option 82 field to DHCP messages is enabled, you can use the dhcp option82 format command to configure the format of the Option 82 field.

If you run the dhcp option82 format command in the system view, the command takes effect for all the DHCP messages on all the interfaces of the device.

You can use the following keywords to define the Option 82 field. The format string can use the hexadecimal notation, ASCII format, or combination of the two formats.
  • sysname: indicates the ID of the access point. This keyword is valid only in ASCII format.
  • portname: indicates the name of a port, for example, GE0/0/1. This keyword is valid only in ASCII format.
  • porttype: indicates the type of a port. This keyword is a character string or in hexadecimal notation. For example, if the value is Ethernet in ASCII format, it is 15 in hexadecimal notation.
  • iftype: indicates the type of an interface, which can be eth or trunk. This keyword is valid only in ASCII format.
  • mac: indicates the MAC address of a port. In ASCII format, the value is in the format of H-H-H; in hexadecimal notation, the value is a number of six bytes.
  • slot: indicates the slot ID. This keyword is valid in ASCII format or in hexadecimal notation.
  • subslot: indicates the subslot ID. This keyword is valid in ASCII format or in hexadecimal notation.
  • port: indicates the port number. This keyword is valid in ASCII format or in hexadecimal notation.
  • svlan: indicates the outer VLAN ID. The value ranges from 1 to 4094. If this field is not required, this field is 0. This keyword is valid in ASCII format or in hexadecimal notation.
  • cvlan: specifies the inner VLAN ID. The value ranges from 1 to 4094. If this field is not required, this field is 0. This keyword is valid in ASCII format or in hexadecimal notation.
  • length: indicates the total length of the keywords following the keyword length.
  • n: indicates the value of the keyword svlan or cvlan if the SVLAN or CVLAN does not exist. The keyword n is on the left of the keyword svlan or cvlan. If the corresponding VLAN does not exist, the default value of the keyword svlan or cvlan is 4096 in ASCII format and is all Fs in hexadecimal notation. If the n keyword is added to the left of the keyword svlan or cvlan, the keyword svlan or cvlan is 0. This keyword is valid in ASCII format or in hexadecimal notation.

Delimiters must be added between keywords; otherwise, the device cannot parse the keywords. The delimiters cannot be numbers.

The keyword length can be configured only once.

The symbols used in the format string are as follows:
  • The symbol % followed by a keyword indicates the format of the keyword.
  • A number to the left of the symbol % indicates the length of the keyword following the symbol %. In an ASCII character string, %05 has the same meaning as %05d in the C language. In a hexadecimal character string, the number indicates the keyword length in bits.
  • The symbol [] indicates an optional keyword. Each pair of brackets can contain only one keyword, svlan or cvlan. The keyword in the symbol [] is added to the Option 82 field only if the corresponding VLAN ID exists. To facilitate syntax check, the system does not support nesting of symbols [].
  • The symbol \ indicates an escape character. The symbols %, \, and [] following the escape character indicate themselves. For example, \\ represents \.
  • The contents in quotation marks (" ") are encapsulated in a character string, and the contents outside the quotation marks are encapsulated in hexadecimal notation.
  • Other symbols are processed as common characters. The rules for setting the format string in ASCII format or hexadecimal notation are as follows:
    • An ASCII character string can contain Arabic numerals, uppercase letters, lowercase letters, and the following symbols: ! @ # $ % ^ & * ( ) _ + | - = \ [ ] { } ; : ' " / ? . , < > `.
    • By default, the length of each keyword in an ASCII character string is the actual length of the keyword.
    • A hexadecimal notation string can contain numerals, spaces, and % + keywords.
    • In a hexadecimal notation string, numbers are encapsulated in the Option 82 field in hexadecimal notation. A number from 0 to 255 occupies 1 byte; a number from 256 to 65535 occupies 2 bytes; a number from 65536 to 4294967295 occupies 4 bytes. Numbers larger than 4294967295 are not supported. Multiple numbers must be separated by spaces; otherwise, they are considered as one number.
    • All the spaces in a hexadecimal character string are ignored.
    • By default, the slot ID, subslot ID, port number, and VLAN ID in a hexadecimal character string occupy 2 bytes; the field length occupies 1 byte.
    • If the length of each keyword in a hexadecimal character string is specified, the total length of the hexadecimal character string must be a multiple of 8. If the length of a specified keyword is longer than 32 bits, the first 32 bits of the keyword are the actual keyword value, and other bits are set to 0.
    • A hexadecimal notation string can contain only the keywords whose values are numbers. Other keywords, such as port name, cannot be added to the hexadecimal notation string.
    • If a string is not contained in quotation marks, it is encapsulated in hexadecimal notation. To encapsulate the string in the ASCII format, use a pair of quotation marks to contain the string. For example, the slot ID is 3, and the port number is 4. If the string is in the %slot %port format, the value of the encapsulated string is a hexadecimal number 00030004. If the string is in the "%slot %port" format, the value of the encapsulated string is 3 4.
    • A format string can contain both hexadecimal strings and ASCII strings, for example, %slot %port "%sysname %portname:%svlan.%cvlan."

Prerequisites

DHCP has been enabled globally using the dhcp enable command.

Precautions
  • All Option82 fields configured in the system view or in the same interface view share a length of 1-255 bytes. If their total length exceeds 255 bytes, some Option82 information will be lost.

  • There is no limit on the number of Option 82 fields configured on the device. However, a large number of Option 82 fields will occupy a lot of memory and prolong the device processing time. To ensure device performance, you are advised to configure Option 82 fields based on the service requirements and device memory size.

Example

# Configure the default format for the CID in the Option 82 field.

<HUAWEI> system-view
[HUAWEI] dhcp enable
[HUAWEI] dhcp option82 circuit-id format default

# Configure the extended format for the CID and RID in the Option 82 field.

<HUAWEI> system-view
[HUAWEI] dhcp enable
[HUAWEI] dhcp option82 format extend

# Configure the user-defined string for the CID in the Option 82 field and encapsulate the port name, outer VLAN ID, inner VLAN ID, and host name in ASCII format.

<HUAWEI> system-view
[HUAWEI] dhcp enable
[HUAWEI] dhcp option82 circuit-id format user-defined "%portname:%svlan.%cvlan %sysname"

# Configure a hexadecimal notation string for the CID of the Option 82 field and encapsulate the CID type (fixed as 0, indicating the hexadecimal notation), length (excluding the lengths of the CID type and the keyword length itself), outer VLAN ID, slot ID (5 bits), subcard ID (3 bits), and port ID (8 bits).

<HUAWEI> system-view
[HUAWEI] dhcp enable
[HUAWEI] dhcp option82 circuit-id format user-defined 0 %length %svlan %5slot %3subslot %8port

# Configure the user-defined string for the RID in the Option 82 field and encapsulate the device MAC address in hexadecimal notation.

<HUAWEI> system-view
[HUAWEI] dhcp enable
[HUAWEI] dhcp option82 remote-id format user-defined %mac

# On GE0/0/1, configure the default format for the CID in the Option 82 field.

<HUAWEI> system-view
[HUAWEI] dhcp enable
[HUAWEI] interface gigabitethernet 0/0/1
[HUAWEI-GigabitEthernet0/0/1] dhcp option82 circuit-id format default

# On GE0/0/1, configure the extended format for the CID and RID in the Option 82 field of DHCP messages from VLAN 10.

<HUAWEI> system-view
[HUAWEI] dhcp enable
[HUAWEI] interface gigabitethernet 0/0/1
[HUAWEI-GigabitEthernet0/0/1] dhcp option82 vlan 10 format extend

# On GE0/0/1, configure a user-defined format for the CID in the Option 82 field and encapsulate the port name, outer VLAN ID, inner VLAN ID, and host name in ASCII format.

<HUAWEI> system-view
[HUAWEI] dhcp enable
[HUAWEI] interface gigabitethernet 0/0/1
[HUAWEI-GigabitEthernet0/0/1] dhcp option82 circuit-id format user-defined "%portname:%svlan.%cvlan %sysname"

# On GE0/0/1, configure a hexadecimal notation string for the CID of the Option 82 field and encapsulate the CID type (fixed as 0, indicating the hexadecimal notation), length (excluding the lengths of the CID type and the keyword length itself), outer VLAN ID, slot ID (5 bits), subcard ID (3 bits), and port ID (8 bits).

<HUAWEI> system-view
[HUAWEI] dhcp enable
[HUAWEI] interface gigabitethernet 0/0/1
[HUAWEI-GigabitEthernet0/0/1] dhcp option82 circuit-id format user-defined 0 %length %svlan %5slot %3subslot %8port

# On GE0/0/1, configure the user-defined format for the RID in the Option 82 field and encapsulate the device MAC address in hexadecimal notation.

<HUAWEI> system-view
[HUAWEI] dhcp enable
[HUAWEI] interface gigabitethernet 0/0/1
[HUAWEI-GigabitEthernet0/0/1] dhcp option82 remote-id format user-defined %mac
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >