[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ntpd confusion



On Nov 27, 2014, at 11:00 AM, mad <mad@sharktooth.de> wrote:

> I found it. It was DHCP. The NTP init scripts checks if there is a file
> /var/lib/ntp/ntp.conf.dhcp in which the local router is configured as
> only ntp source.

The DHCP client package in Debian tries to get as much information as possible out of the DHCP transaction.  It then makes it available to as many other packages as it can.  I think this is a conscious decision on the part of the Debian Developers, and overall, I support it.  But it sometimes leads to surprises, such as we have seen here.

Specifically, for NTP, when a new NIC comes online and it’s configured for DHCP, the DHCP client checks to see if there is an NTP server provided in the DHCP response packet.  If there is, it copies /etc/ntp.conf to /var/lib/ntp/ntp.conf then strips out *all* lines beginning with “server”.  It then puts at the top of the file a single new “server” line directing ntpd to use the DHCP provided server.

When the ntp init.d script runs, it checks to see if there is a /var/lib/ntp/ntp.conf.dhcp file, and uses it in place of the conventional /etc/ntp.conf.

The result is what you saw.

If you don’t like that behavior, there is a workaround.  With the ntp version distributed in Wheezy (and, possibly,  also Lenny) the ntp.conf file can have a “pool” directive, which is *not* messed with by the DHCP scripts.  So, in /etc/ntp.conf replace the four lines

> server 0.debian.pool.ntp.org iburst
> server 1.debian.pool.ntp.org iburst
> server 2.debian.pool.ntp.org iburst
> server 3.debian.pool.ntp.org iburst

with the one line

> pool us.pool.ntp.org iburst preempt

If you aren’t in the US, try using your own country code in place of “us” as long as

> host <CC>.pool.ntp.org

indicates it exists.  If not, try some nearby countries.   Or, as a complete last resort, you can use just plain “pool.ntp.org” without a country code.

So, assuming you are in Germany, you would use

> pool de.pool.ntp.org iburst preempt


The mechanism behind the “pool” directive is described in more detail at
    http://www.eecis.udel.edu/~mills/ntp/html/discover.html#pool

Enjoy!

Rick
    

Reply to: