Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

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
share|improve this answer
    
I haven't tried this yet, but that certainly looks like the right approach. Thank you. I will give it a try very soon. –  spkane Mar 21 '13 at 16:33

If you don't have access to the DHCP server or don't want to alter the server's configuration you can set the options on the client with a dh-client-exit-hooks script. If you're running Ubuntu you can put a script like this in /etc/dhcp3/dhclient-exit-hooks.d


cd /etc/dhcp3/dhclient-exit-hooks.d
sudo vim resolver-options

#
# Prepend resolver options to /etc/resolv.conf after dhclient`
# regenerates the file. See man (5) resolver for more details.
#
RESOLV_CONF=$(cat /etc/resolv.conf)
OPTIONS="options timeout:1"

echo -e "$OPTIONS\n$RESOLV_CONF" > /etc/resolv.conf

Just add the options you want to $OPTIONS, separating them with a newline (\n) character and the script will run after dhclient exits and prepend the resolver options to /etc/resolv.conf.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.