7

I aim to prohibit dhclient from updating my NTP config with servers received via DHCP, as it is the default on Debian/Ubuntu. However, my DHCP server ignores the list of requested options (from the request setting) and its answers always contain an NTP server.

So I want to remove the option before further processing or at least overwrite it with an empty value. Overwriting is possible using the supersede setting, but I didn't manage to make it empty. I also couldn't find a way to completely delete an option.

What in fact results in an empty value is specifying an invalid one in supersede (e.g. containing letters, as only numerical values are allowed). This is actually invalid and causes errors in the logfile though. Is anyone aware of a better way?

  • prepend doesn't do what you want? Also which options are you looking to override? – slm Mar 17 '14 at 2:03
  • From my understanding, prepend adds additional values to the front of the response. I want to completely replace the ntp-servers option with an empty value or remove it at all. – F30 Mar 17 '14 at 8:34
2

Easy way:

# rm /etc/dhcp/dhclient-exit-hooks.d/ntp
  • 1
    I had already done that, but just couldn't believe that there's not also a way to ignore certain parts of a response in the first place. As it stands, just deleting the hook still appears to be the best solution. – F30 Mar 25 '14 at 23:55
  • 1
    Did you file a bug report? I was really surprised that supersede did not work when I tried it. it seems like supersede "" should behave like a reject statement. – dfc Mar 26 '14 at 4:04
  • 1
    I did file a feature request with ISC now. Unfortunately, they don't have a public bug tracker, but it's ISC bug #35631. Debian bug #672232 also deals with a similar topic. – F30 Mar 30 '14 at 11:35
-1

I think you can configure your dhclient via the `/etc/dhclient.conf file telling it which options you want it to formally request values for from your DHCP server.

Example

request subnet-mask, broadcast-address, routers, domain-name, 
    domain-name-servers, host-name;

You can find out more about this via the dhclient.conf man page.

excerpt

There  is a variety of data contained in offers that DHCP servers send to 
DHCP clients.  The data that can be specifically requested is what are
called DHCP Options.  DHCP Options are defined in dhcp-options(5).

The request statement

 [ also ] request [ [ option-space . ] option ] [, ... ];

The request statement causes the client to request that any server 
responding to the client  send  the  client  its  values  for  the  
specified options.   Only  the  option names should be specified in the 
request statement - not option parameters.  By default, the DHCPv4 client 
requests the subnet-mask, broadcast-address, time-offset, routers, 
domain-search, domain-name, domain-name-servers, host-name,  nis-domain, 
nis-servers, ntp-servers and interface-mtu options while the DHCPv6 client 
requests the dhcp6 name-servers and domain-search options.  Note that if you
enter a ´request´ statement, you over-ride these defaults and these options 
will not be requested.

In some cases, it may be desirable to send no parameter request list at all.  
To do this, simply write the  request  statement  but  specify  no 
parameters:

    request;

In most cases, it is desirable to simply add one option to the request list 
which is of interest to the client in question.  In this case, it is best to 
´also request´ the additional options:

    also request domain-search, dhcp6.sip-servers-addresses;

Disabling via /dhclient-exit-hooks.d?

Poking around a 12.10 install of Ubuntu I noticed this directory, /etc/dhcp/dhclient-exit-hooks.d with this file inside it, ntpdate. Looking at this file it contains a shell script that will perform the update on a system when a lease is acquired or released via DHCP. You could disable the updating of your NTP server through this script, by simply commenting out this file:

ntp_servers_setup() {
    case $reason in
        BOUND|RENEW|REBIND|REBOOT)
            ntp_servers_setup_add
            ;;
        EXPIRE|FAIL|RELEASE|STOP)
            ntp_servers_setup_remove
            ;;
    esac
}


ntp_servers_setup
  • As I said, my DHCP server's answer contains the particular option regardless of what was requested. – F30 Mar 17 '14 at 8:30
  • Your appended solution basically appears to be the best, see also @dfc's answer. However, the respective hook is ntp and not ntpdate. The latter just writes the config for the ntpdate CLI tool , which has little to do with the NTP daemon. – F30 Mar 25 '14 at 23:51
  • @F30 - Yes I saw his solution, that seemed a bit heavy handed to have to do it that way but if it works it works. The hooks must be different then across Debian/Ubuntu, as I stated that hook, ntpdate, is directly from a 12.10 Ubuntu install. What ver. of Debian/Ubuntu are you using anyway? – slm Mar 26 '14 at 0:25
  • I'm running Ubuntu 13.10. The ntpdate hook is present as well (and part of the default installation), but as stated above it only produces a config for the CLI tool. This makes no difference as long as you don't call ntpdate. If the NTP daemon (package "ntp") is installed, there also is the ntp hook. That establishes an additional ntp.conf and also restarts the daemon, which then prefers the new config. – F30 Mar 26 '14 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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