[pkg-ntp-maintainers] Bug#766838: ntpdate runs before dhcp-client has configured the network interface

Hartmut Buhrmester Aeghair5-heiWohv3 at t-online.de
Wed Nov 30 00:28:58 UTC 2016


A possible fix for this bug would be to insert a short break, before 
ntpdate is called.

I noticed, that the configuration file /etc/network/if-up.d/ntpdate 
creates a subshell, which is started in the background. Then it should 
be possible to insert a short break of about two seconds, before ntpdate 
is called. This will be enough time for dhcp-client to finish the 
initialization of the network interface. Some more time may be needed 
for dial-up connections with ppp.

(

### Include a short break to let dhcp-client finish ###
sleep 2s

# This is for the case that /usr will be mounted later.
if [ -r /lib/udev/hotplug.functions ]; then
         . /lib/udev/hotplug.functions
         wait_for_file /usr/sbin/ntpdate-debian
fi

LOCKFILE=/var/lock/ntpdate

# Avoid running more than one at a time
if [ -x /usr/bin/lockfile-create ]; then
         lockfile-create $LOCKFILE
         lockfile-touch $LOCKFILE &
         LOCKTOUCHPID="$!"
fi

/usr/sbin/ntpdate-debian -s $OPTS 2>/dev/null || :

if [ -x /usr/bin/lockfile-create ] ; then
         kill $LOCKTOUCHPID
         lockfile-remove $LOCKFILE
fi

) &


Then I get in /var/log/syslog:

> Nov 30 00:46:50 debian networking[394]: Configuring network interfaces...done.
> Nov 30 00:46:50 debian systemd[1]: Started LSB: Raise network interfaces..
> Nov 30 00:46:50 debian systemd[1]: Starting ifup for eth0...
> Nov 30 00:46:50 debian systemd[1]: Started ifup for eth0.
> Nov 30 00:46:50 debian systemd[1]: Starting Network.
> Nov 30 00:46:50 debian systemd[1]: Reached target Network.
> Nov 30 00:46:50 debian systemd[1]: Starting Network is Online.
> Nov 30 00:46:50 debian systemd[1]: Reached target Network is Online.
> Nov 30 00:46:50 debian systemd[1]: Starting LSB: RPC portmapper replacement...
> Nov 30 00:46:50 debian console-setup[440]: Setting up console font and keymap...done.
> Nov 30 00:46:50 debian systemd[1]: Started LSB: Set console font and keymap.
> Nov 30 00:46:50 debian dhclient: Internet Systems Consortium DHCP Client 4.3.1
> Nov 30 00:46:50 debian ifup[493]: Internet Systems Consortium DHCP Client 4.3.1
> Nov 30 00:46:50 debian dhclient: Copyright 2004-2014 Internet Systems Consortium.
> Nov 30 00:46:50 debian dhclient: All rights reserved.
> Nov 30 00:46:50 debian dhclient: For info, please visit https://www.isc.org/software/dhcp/
> Nov 30 00:46:50 debian dhclient:
> Nov 30 00:46:50 debian ifup[493]: Copyright 2004-2014 Internet Systems Consortium.
> Nov 30 00:46:50 debian ifup[493]: All rights reserved.
> Nov 30 00:46:50 debian ifup[493]: For info, please visit https://www.isc.org/software/dhcp/
> Nov 30 00:46:50 debian rpcbind[495]: Starting rpcbind daemon....
> Nov 30 00:46:50 debian systemd[1]: Started LSB: RPC portmapper replacement.
> Nov 30 00:46:50 debian systemd[1]: Starting RPC Port Mapper.
> Nov 30 00:46:50 debian systemd[1]: Reached target RPC Port Mapper.
> Nov 30 00:46:50 debian systemd[1]: Starting LSB: NFS support files common to client and server...
> Nov 30 00:46:50 debian dhclient: Listening on LPF/eth0/00:11:50:9b:ef:be
> Nov 30 00:46:50 debian dhclient: Sending on   LPF/eth0/00:11:50:9b:ef:be
> Nov 30 00:46:50 debian dhclient: Sending on   Socket/fallback
> Nov 30 00:46:50 debian dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 4
> Nov 30 00:46:50 debian ifup[493]: Listening on LPF/eth0/00:11:50:9b:ef:be
> Nov 30 00:46:50 debian ifup[493]: Sending on   LPF/eth0/00:11:50:9b:ef:be
> Nov 30 00:46:50 debian ifup[493]: Sending on   Socket/fallback
> Nov 30 00:46:50 debian ifup[493]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 4
> Nov 30 00:46:50 debian dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
> Nov 30 00:46:50 debian dhclient: DHCPOFFER from 192.168.2.1
> Nov 30 00:46:50 debian ifup[493]: DHCPREQUEST on eth0 to 255.255.255.255 port 67
> Nov 30 00:46:50 debian ifup[493]: DHCPOFFER from 192.168.2.1
> Nov 30 00:46:50 debian dhclient: DHCPACK from 192.168.2.1
> Nov 30 00:46:50 debian ifup[493]: DHCPACK from 192.168.2.1
> Nov 30 00:46:50 debian rpc.statd[555]: Version 1.2.8 starting
> Nov 30 00:46:50 debian sm-notify[556]: Version 1.2.8 starting
> Nov 30 00:46:50 debian dhclient: bound to 192.168.2.100 -- renewal in 667020440 seconds.
> Nov 30 00:46:50 debian ifup[493]: bound to 192.168.2.100 -- renewal in 667020440 seconds.
> [...]
> Nov 30 00:47:12 debian ntpdate[641]: step time server 131.234.137.64 offset -1.014189 sec
> Nov 30 00:47:12 debian systemd[882]: Time has been changed
> Nov 30 00:47:12 debian systemd[1]: Time has been changed
> Nov 30 00:47:16 debian dbus[598]: [system] Activating via systemd: service name='org.freedesktop.PolicyKit1' unit='po
> Nov 30 00:47:16 debian systemd[1]: Starting Authenticate and Authorize Users to Run Privileged Tasks...
> Nov 30 00:47:16 debian polkitd[980]: started daemon version 0.105 using authority implementation `local' version `0.1
> Nov 30 00:47:16 debian dbus[598]: [system] Successfully activated service 'org.freedesktop.PolicyKit1'
> Nov 30 00:47:16 debian systemd[1]: Started Authenticate and Authorize Users to Run Privileged Tasks.
> Nov 30 00:47:28 debian ntpdate[986]: adjust time server 131.234.137.64 offset -0.001715 sec

Of course, for this test I disabled the script /etc/cron.daily/ntpdate, 
which I mentioned in my previous post.

So a short break allows ntpdate to succeed without changing the way it 
is invoked, e.g. there is no need to create additional cron jobs or init 
scripts.

-- 
Hartmut Buhrmester



More information about the pkg-ntp-maintainers mailing list