Centos – Is is possible to configure ISC’s DHCPD to configure resolv.conf options like timeout and attempts

centosdhcpdoptionsresolv.conf

The resolv.conf supports a line called options that allows for some fine tuning of the behavior of the resolver. In my environment we are using ISC's DHCPD to provide DHCP services to our services. Currently I can set the search and nameserver fields in the resolv.conf fine via DHCP, but I also want to be able to create the following line:

options timeout:2 attempts:4

Does anyone know if this is possible?

I have the following resolver related DHCPD options set currently:

  option domain-search            "example.com";
  option domain-name-servers      192.168.1.1, 192.168.1.2, 192.168.1.3, 192.168.1.4;

In this particular case, the systems are all running CentOS 5/6.

Best Answer

There isn't an existing DHCP option for this, so you have to add custom configuration to both the server and clients in order to support this.

On the server (/etc/dhcp/dhcpd.conf), define a new option and set the value:

option resolv-options code 224 = text;
option resolv-options "timeout:2 attempts:4";

On the client (/etc/dhcp/dhclient.conf), define the new option and add it to the list of options to request:

option resolv-options code 224 = text;
request ..., resolv-options;

Then add a hook (/etc/dhcp/dhclient-enter-hooks.d/resolvoptions) on the client to actually use the sent value:

if [ "$new_resolv_options" ]; then
    echo "options $new_resolv_options" >> /etc/resolv.conf
fi