dhcp option82 format (interface view)

Function

The dhcp option82 format command configures the format of Option 82 in DHCP packets.

The undo dhcp option82 format command restores the default format of Option 82 in DHCP packets.

By default, Option 82 in DHCP packets is in the type1 format.

Format

dhcp option82 format { self-define extendText | type1 | type2 | cn-telecom | cn-telecom-inherit }

dhcp option82 [ circuit-id | remote-id ] format user-defined text

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

Parameters

Parameter Description Value
circuit-id

Indicates sub-option 1 of option 82: circuit-id (CID).

-

remote-id

Indicates sub-option 2 of option 82: remote-id (RID).

-

self-define extendText

Specifies a user-defined DHCP Option 82 format.

The value is a string of 1 to 255 case-insensitive characters. It can contain letters, digits, and special characters.

type1

Indicates the Telecom format of Option 82.

CID format: interface name:outer VLAN ID.inner VLAN ID system name/0/0/0/0/0, in ASCII encapsulation mode.

-

type2

Indicates the NMS format of Option 82.

CID format: interface name:outer VLAN ID.inner VLAN ID system name, in ASCII encapsulation mode.

-

cn-telecom

Indicates the Option 82 information in the standard cn-telecom format.

CID format: interface name:outer VLAN ID.inner VLAN ID /0/0/0/0/0/0, in ASCII encapsulation mode.

-

cn-telecom-inherit

Option 82 information in the standard cn-telecom format is inherited.

CID format: inherits the access node information in the DHCP request packet and fills in the location information.

-

user-defined text

Specifies the self-defined format string of option 82.

The value is a string of 1 to 255 characters. For the value requirements of the user-defined format character string, see the following "Usage Guidelines".

Views

100GE interface view, 10GE interface view, 25GE interface view, 400GE Layer 2 sub-interface view, 400GE interface view, 40GE interface view, 50GE Layer 2 sub-interface view, 50GE interface view, Eth-Trunk Layer 2 sub-interface view, Eth-Trunk interface view, FlexE sub-interface view, FlexE interface view, GE Layer 2 sub-interface view, GE optical interface view, GE interface view, GE electrical interface view, Global VE sub-interface view, VE sub-interface view, Layer 2 sub-interface view, Sub-interface view

Default Level

2: Configuration level

Task Name and Operations

Task Name Operations
dhcp write

Usage Guidelines

Usage Scenario

The option 82 contains the location information of DHCP clients, such as information about login interface, VLAN, and address. After the option 82 field is configured, the device can set up dynamic binding entries with accurate interface information. Based on the option 82 field, the DHCP server assigns IP addresses and policies for DHCP clients.

After a self-define Option 82 format is configured, the device encapsulates the self-define Option 82 format into packets.

In addition, you can use the following keywords to define the user-defined option 82 format string. The format string can use the hexadecimal format, ASCII format, or combination of the two formats.

  • sysname: indicates the ID of the access point. This keyword is valid only in the ASCII mode.
  • portname: specifies the name of a port, for example, GE0/1/0. This keyword is valid only in the ASCII mode.
  • porttype: indicates the type of a port. This keyword is valid in the ASCII format and hexadecimal format. For example, if the value is Ethernet in the ASCII format, it is 15 in hexadecimal notation.
  • iftype: indicates the type of a port, including eth and trunk. This keyword is valid only in the ASCII mode.
  • mac: indicates the MAC address of a port. In the ASCII format, the value is expressed as H-H-H; in hexadecimal notation, the value is a number of six bytes.
  • slot: indicates the slot ID. This keyword is valid in the ASCII format and hexadecimal format.
  • subslot: specifies the subslot ID. This keyword is valid in the ASCII format and hexadecimal format.
  • port: indicates the port number. This keyword is valid in the ASCII format and hexadecimal format.
  • svlan: indicates the outer VLAN ID. The value ranges from 0 to 4095. If this field is not required, this field is set to 0. This keyword is valid in the ASCII format and hexadecimal format.
  • cvlan: specifies the inner VLAN ID. The value ranges from 0 to 4095. If this field is not required, this field is set to 0. This keyword is valid in the ASCII format and hexadecimal format.
  • length: indicates the total length of the following keywords excluding the length keyword.
  • n: indicates the value of the svlan or cvlan keyword if the outer VLAN ID or inner VLAN ID does not exist. The n keyword is on the left of the svlan or cvlan keyword. If the corresponding VLAN does not exist, the default value of the svlan or cvlan keyword is 4096 in the ASCII format and is all Fs in the hexadecimal format. If the n keyword is added to the left of the svlan or cvlan keyword, the svlan or cvlan keyword is set to 0. This keyword is valid in the ASCII format and hexadecimal format.

    Keywords must be separated by delimiters. Otherwise, they cannot be parsed. The delimiters cannot be numbers.

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

    If the VLAN ID is specified in the dhcp option82 format command, the system constructs the format of option 82 as follows:
  • If the outer VLAN ID in DHCP packets received on an interface is the same as the specified VLAN ID, the interface constructs option 82 according to the format set on the interface through the dhcp option82 format command.
  • If the outer VLAN ID in DHCP packets received on an interface is the different from the specified VLAN ID, the interface constructs option 82 according to the globally configured format.

Prerequisites

Perform the following operations before running the command:

  1. Globally enable DHCP using the dhcp enable command.
  2. Enable the Option 82 inserting function as required.
  • Run the dhcp option82 insert enable (interface view) command to enable a device to insert Option 82 into DHCP packets. If no Option 82 field exists in a received DHCP packet, the device inserts the Option 82 field into the packet. If the Option 82 field exists in a received DHCP packet, the device checks whether the Option 82 field contains sub-options. If the Option 82 field contains sub-options, the device does not change the sub-options. If the Option 82 field does not contain sub-options and the sub-option format is configured, the device inserts sub-options into the Option 82 field.
  • Run the dhcp option82 rebuild enable (interface view) command to enable a device to forcibly insert Option 82 into DHCP packets. If no Option 82 field exists in a received DHCP packet, the device inserts the Option 82 field into the packet. If the Option 82 field exists in a DHCP packet, the device deletes the Option 82 field and inserts a new Option 82 field into the packet.

Precautions

  1. If the length of the Option 82 field in self-define format exceeds 253 bytes, the Option 82 field is truncated, and only the first 253 bytes are added to the Option 82 field.
  2. If suboption 1 and suboption 2 of Option 82 are in self-define format and the total length exceeds 251 bytes, the Option 82 field is truncated, and only the content of suboption 1 is added to the Option 82 field.
  3. Only one of the user-defined, self-define, type1, type2, cn-telecom, and cn-telecom-inherit formats can be configured. If the configured format of the Option 82 field changes, the new configuration overwrites the old configuration.

Example

# Set the Option 82 format to type1 on GE 0/1/1 so that Option 82 in Telecom format, such as Ethernet0/1/0:0.0 HUAWEI/0/0/0/0/0, is encapsulated in packets.
<HUAWEI> system-view
[~HUAWEI] dhcp enable
[~HUAWEI] interface GigabitEthernet 0/1/1
[~HUAWEI-GigabitEthernet0/1/1] dhcp option82 insert enable
[*HUAWEI-GigabitEthernet0/1/1] dhcp option82 format type1
# Set the Option 82 format to self-define on GE 0/1/1 so that the testCase character string is encapsulated in packets.
<HUAWEI> system-view
[~HUAWEI] dhcp enable
[~HUAWEI] interface GigabitEthernet 0/1/1
[~HUAWEI-GigabitEthernet0/1/1] dhcp option82 insert enable
[*HUAWEI-GigabitEthernet0/1/1] dhcp option82 format self-define testCase
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >