Saturday, February 09, 2013

Adding custom options in ISC-DHCPD's dhcpd.conf

There was a need to add a custom option code 138 into ISC-DHCPD to facilitate our wireless controllers and CAPWAP for its managed access points. Following is the excerpt required in dhcpd.conf:

#CAPWAP Settings
option capwap code 138 = ip-address;
option capwap 0x0A102001;
if exists dhcp-parameter-request-list {
option dhcp-parameter-request-list=concat(option dhcp-parameter-request-list,8A);

Explaination as below:

option capwap code 138 = ip-address;
This line declares a namespace "capwap" which should return dhcp-option code 138 and it should take values in the format of ip-adresses.

In ISC-DHCP, ip-address values takes the form of octal representation such as or in hexadecimal representation such as 0xC0A80101

Other types of *common* values are strings and arrays of ip-address (ip-address separated by a comma',')

...option capwap 0x0A102001;
This is the actual variable=value line. In the sample above, it is declared in the global declarations, it can also be specified in the pool declarations.

...option dhcp-parameter-request-list=concat(option dhcp-parameter-request-list,8A);
Without this line, ISC-DHCPD will *never* include the custom options in its DHCP offer messages. The item 8A refers to the custom dhcp-option 138 in hexadecimal representation. For multiple custom options, separate the dhcp-parameter-request-list values with commas. For example:

...option dhcp-parameter-request-list=concat(option dhcp-parameter-request-list,8A,8B,8C);
This represents custom option for dhcp-option 138,139 and 140