Netsh Classless Static Route DHCP Option

commanddhcpnetsh

I want to add netsh command to set Classless Static Route 249 in DHCP Scope, I use this command but it gave me an erorr, I am using windows server 2003 R2

netsh dhcp server \SRVDC01 scope 10.0.17.45 set optionvalue 249 IPADDRESS 10.0.0.0 255.0.0.0 10.0.16.1

Best Answer

I suspect the errors you're seeing are:

Option data type supplied is not valid for the Option.

DHCP Server Set OptionValue failed.

Parameter(s) passed are either incomplete or invalid.

You're seeing these because option 249 must be specified as as BINARY value, not as an IPADDRESS value.

If you can't set this with the GUI then you'll have to convert your desired route into a hexadecimal string yourself. An example would be as follows: 10.1.1.0/24 accessible via 10.1.1.1 converts into "180a01010a010101". The first octet, "18", is the number of bits of subnet mask (0x18 = 24 decimal). The next octets are the network ID (0a = 10, 01 = 1, 01 = 1, for "10.1.1"), padded by zeros on the right if the subnet mask doesn't end on an even octet boundary. The last four octets are the IP address of the gateway.

Set the value in the GUI and you'll be happier.