Windows 2003 DHCP server add options

Thu 04 November 2010


配置dhcp作用域后,在dhcp server策略配置下无法直接添加新的option,需要使用netsh命令添加。

如需添加option 128 string类型的,命令如下:

netsh dhcp>server \server_name
netsh dhcp server>add optiondef 128 TestName String


netsh dhcp add optiondef的命令格式:

add optiondef

Adds a new option type definition to the specified DHCP server.

add optiondef OptCode OptName {BYTE | WORD | DWORD | STRING | IPADDRESS} [[IsArray=]{0 | 1}] [vendor=VendorClass] [comment=OptComment] [DefValue]

OptCode : Required. Specifies the option type to define. Identifies the option type with a unique option code. For the value of the code, choose a number between 0 and 255.

OptName : Required. Specifies the name of the option type.

{BYTE | WORD | DWORD | STRING | IPADDRESS} : Required. Indicates the data type of the option.

[IsArray=]{0 | 1} : Indicates whether the data type is arrayed or non-arrayed: 0-Unary or non-arrayed (default), 1-Arrayed.

vendor=VendorClass : Specifies the vendor class for the option. If unspecified, the default vendor class, the DHCP standard options class, is used.

comment=OptComment : Specifies a comment to add to the new option type definition. If unspecified, the default value is NULL.

DefValue : Specifies a default value to use for this option type, if one is not specified otherwise.

IsArray must be 0 for STRING type options.

In the first example, this command defines a new option type named ExtensionsPath with code 18, a STRING data type, and joins it to the DHCP standard options class, assigning it a default value of c:temp.

In the second and third examples, this command defines a new option type named TestOption with code 231 and an IPADDRESS data type. In the second example, the option is defined to provide only a single IP address. IsArray and DefValue are not necessary because defaults are assumed. In the third example, DefValue, and IsArray are required to create an array containing the IP address values,, and

add optiondef 18 ExtensionsPath STRING 0 c:temp

add optiondef 231 TestOption IPADDRESS

add optiondef 231 TestOption IPADDRESS 1 vendor=MyVendorClass