The dhcp server option command sets user-defined option for an interface address pool.
The undo dhcp server option command deletes user-defined option from an interface address pool.
By default, no user-defined option is configured in an interface address pool.
dhcp server option code [ sub-option sub-code ] { ascii ascii-string | hex hex-string | cipher cipher-string | ip-address ip-address &<1-8> }
undo dhcp server option [ code [ sub-option sub-code ] ]
Parameter |
Description |
Value |
---|---|---|
code |
Specifies the code for a user-defined option. |
The value is an integer that ranges from 1 to 254, except values 1, 3, 6, 15, 44, 46, 50, 51, 52, 53, 54, 55, 57, 58, 59, 61, 82, 120, 121 and 184.
NOTE:
|
sub-option sub-code |
Specifies the code of a user-defined sub-option. |
The value is an integer that ranges from 1 to 254. For details about well-known options, see RFC 2132. |
ascii ascii-string |
Specifies the user-defined option code as an ASCII character string. |
The value is a string of 1 to 255 characters when sub-option is not specified, or a string of 1 to 253 characters when sub-option is specified. |
hex hex-string |
Specifies the user-defined option code as a hexadecimal string. |
The value is a hexadecimal string with an even number of digits, for example, hh or hhhh. If sub-option is not specified, the even number is in the range of 2 to 254. If sub-option is specified, the even number is in the range of 2 to 252. The value can be a combination of digits (0-9) and letters (A-F and a-f). |
cipher cipher-string |
Specifies the user-defined option code as a ciphertext character string. |
The value is a string, you can enter a character string in explicit text or cipher text.
No matter whether the character string is entered in explicit or cipher text, the character string is displayed in cipher text in the configuration file and in explicit text in packets. |
ip-address ip-address |
Specifies the user-defined option code as an IP address. |
The value is in dotted decimal notation. |
Usage Scenario
This command applies to DHCP servers. The Option field in a DHCP packet carries control information and parameters, including basic information such as the DNS service, NetBIOS service, and IP address lease. If a DHCP server is configured with option, when a DHCP client applies for an IP address from an interface address pool, the client can obtain configurations in the Option field of the DHCP response packet from the DHCP server without having to configure the DNS service, NetBIOS service, or IP address lease separately.
Prerequisites
IP addresses in the interface address pool have been configured using the ip address command.
The DHCP server function has been enabled on the interface using the dhcp select interface command.
Precautions
When users on an enterprise's intranet use a proxy server to connect to the Internet, you need to configure proxy server parameters so that users can use browsers to access the network. The Web Proxy Auto-Discovery Protocol (WPAD) implements automatic configuration of these parameters. The administrator does not need to manually configure these parameters on each client. To implement the WPAD function, the administrator needs to deploy the configuration file of the proxy server in advance, and then run the dhcp server option 252 asciiascii-string command to specify the URL of the configuration file. The ascii-string parameter specifies the URL of the configuration file, in the format of http://xxx/proxy.pac. Set ascii-string according to the actual location of the configuration file. When a browser accesses the network, the browser requests the DHCP server to send the URL of the configuration file on the proxy server, and then downloads the configuration file to conduct automatic configuration. After the configuration is completed, the browser can access the network.
The value of ascii-string cannot be enclosed in double quotation marks as "ascii-string". Otherwise, terminals cannot parse Option252.
<HUAWEI> system-view [HUAWEI] dhcp enable [HUAWEI] interface vlanif 100 [HUAWEI-Vlanif100] ip address 10.10.10.10 24 [HUAWEI-Vlanif100] dhcp select interface [HUAWEI-Vlanif100] dhcp server option 64 hex 11
<HUAWEI> system-view [HUAWEI] dhcp enable [HUAWEI] interface gigabitethernet 0/0/1 [HUAWEI-GigabitEthernet0/0/1] undo portswitch [HUAWEI-GigabitEthernet0/0/1] ip address 10.10.10.10 24 [HUAWEI-GigabitEthernet0/0/1] dhcp select interface [HUAWEI-GigabitEthernet0/0/1] dhcp server option 64 hex 11