isc-dhcp-client: exit hook removes timesyncd.conf.d/01-dhclient.conf if second DHCP client gets no DHCPOFFERS

Vincent Lefevre vincent at vinc17.net
Thu Jun 26 12:20:02 BST 2025


Control: reassign -1 systemd-timesyncd
Control: found -1 257.6-1
Control: found -1 257.7-1
Control: retitle -1 systemd-timesyncd: dhclient exit hook removes timesyncd.conf.d/01-dhclient.conf if second DHCP client gets no DHCPOFFERS

I forgot to change the package name after noticing that the
cause was in the dhclient exit hook, which is provided by
systemd-timesyncd. So reassigning...

BTW, I noticed the bug also before upgrading to 257.7-1.

Repeating what I said in the initial report:

My machine has 2 Ethernet interfaces: enp1s0 and enp0s31f6.
The Ethernet cable can be plugged into either of them.
So I currently have in the /etc/network/interfaces file:

allow-hotplug enp1s0
iface enp1s0 inet dhcp

allow-hotplug enp0s31f6
iface enp0s31f6 inet dhcp

In the journalctl output, I can see:

Jun 26 12:27:40 disset dhclient[1163]: DHCPDISCOVER on enp1s0 to 255.255.255.255 port 67 interval 20
Jun 26 12:27:40 disset ifup[1163]: DHCPDISCOVER on enp1s0 to 255.255.255.255 port 67 interval 20
Jun 26 12:27:42 disset dhclient[1160]: DHCPDISCOVER on enp0s31f6 to 255.255.255.255 port 67 interval 14
Jun 26 12:27:42 disset ifup[1160]: DHCPDISCOVER on enp0s31f6 to 255.255.255.255 port 67 interval 14
Jun 26 12:27:42 disset dhclient[1160]: DHCPOFFER of 140.77.12.53 from 140.77.1.11
Jun 26 12:27:42 disset ifup[1160]: DHCPOFFER of 140.77.12.53 from 140.77.1.11
Jun 26 12:27:42 disset dhclient[1160]: DHCPREQUEST for 140.77.12.53 on enp0s31f6 to 255.255.255.255 port 67
Jun 26 12:27:42 disset ifup[1160]: DHCPREQUEST for 140.77.12.53 on enp0s31f6 to 255.255.255.255 port 67
Jun 26 12:27:42 disset dhclient[1160]: DHCPACK of 140.77.12.53 from 140.77.1.11
Jun 26 12:27:42 disset ifup[1160]: DHCPACK of 140.77.12.53 from 140.77.1.11
Jun 26 12:27:42 disset systemd[1]: Stopping systemd-timesyncd.service - Network Time Synchronization...
Jun 26 12:27:43 disset systemd[1]: systemd-timesyncd.service: Deactivated successfully.
Jun 26 12:27:43 disset systemd[1]: Stopped systemd-timesyncd.service - Network Time Synchronization.
Jun 26 12:27:43 disset systemd[1]: Starting systemd-timesyncd.service - Network Time Synchronization...
Jun 26 12:27:43 disset systemd[1]: Started systemd-timesyncd.service - Network Time Synchronization.
Jun 26 12:27:43 disset systemd-timesyncd[1929]: Contacted time server 140.77.1.32:123 (140.77.1.32).
Jun 26 12:27:43 disset systemd-timesyncd[1929]: Initial clock synchronization to Thu 2025-06-26 12:27:43.493812 CEST.
Jun 26 12:27:43 disset dhclient[1160]: bound to 140.77.12.53 -- renewal in 34051 seconds.
Jun 26 12:27:43 disset ifup[1160]: bound to 140.77.12.53 -- renewal in 34051 seconds.
[...]
Jun 26 12:28:00 disset dhclient[1163]: DHCPDISCOVER on enp1s0 to 255.255.255.255 port 67 interval 9
Jun 26 12:28:00 disset ifup[1163]: DHCPDISCOVER on enp1s0 to 255.255.255.255 port 67 interval 9
Jun 26 12:28:09 disset dhclient[1163]: DHCPDISCOVER on enp1s0 to 255.255.255.255 port 67 interval 12
Jun 26 12:28:09 disset ifup[1163]: DHCPDISCOVER on enp1s0 to 255.255.255.255 port 67 interval 12
Jun 26 12:28:21 disset dhclient[1163]: DHCPDISCOVER on enp1s0 to 255.255.255.255 port 67 interval 14
Jun 26 12:28:21 disset ifup[1163]: DHCPDISCOVER on enp1s0 to 255.255.255.255 port 67 interval 14
Jun 26 12:28:35 disset dhclient[1163]: No DHCPOFFERS received.
Jun 26 12:28:35 disset ifup[1163]: No DHCPOFFERS received.
Jun 26 12:28:35 disset ifup[1163]: No working leases in persistent database - sleeping.
Jun 26 12:28:35 disset dhclient[1163]: No working leases in persistent database - sleeping.
Jun 26 12:28:35 disset systemd[1]: Stopping systemd-timesyncd.service - Network Time Synchronization...
Jun 26 12:28:35 disset systemd[1]: systemd-timesyncd.service: Deactivated successfully.
Jun 26 12:28:35 disset systemd[1]: Stopped systemd-timesyncd.service - Network Time Synchronization.
Jun 26 12:28:35 disset systemd[1]: Starting systemd-timesyncd.service - Network Time Synchronization...
Jun 26 12:28:35 disset systemd[1]: Started systemd-timesyncd.service - Network Time Synchronization.
Jun 26 12:28:35 disset systemd-timesyncd[2546]: Contacted time server 62.210.136.236:123 (0.debian.pool.ntp.org).
Jun 26 12:28:35 disset systemd-timesyncd[2546]: Initial clock synchronization to Thu 2025-06-26 12:28:35.789470 CEST.

So the NTP server has switched from 140.77.1.32 (obtained via DHCP
for enp0s31f6) to 62.210.136.236 (which seems to be a default one).

"systemd-analyze cat-config systemd/timesyncd.conf" initially ended
with

# /run/systemd/timesyncd.conf.d/01-dhclient.conf
# NTP server entries received from DHCP server
[Time]
NTP=140.77.1.32

but then these lines disappeared due to the second dhclient process,
which did not get DHCPOFFERS (due to the lack of Ethernet cable for
the associated interface).

The issue seems to be in /etc/dhcp/dhclient-exit-hooks.d/timesyncd,
which creates or removes the 01-dhclient.conf file:

TIMESYNCD_CONF=/run/systemd/timesyncd.conf.d/01-dhclient.conf
[...]
case $reason in
        BOUND|RENEW|REBIND|REBOOT)
                timesyncd_servers_setup_add
                ;;
        EXPIRE|FAIL|RELEASE|STOP)
                timesyncd_servers_setup_remove
                ;;
esac

The dhclient-script(8) man page says for EXPIRE and FAIL:

EXPIRE
       The DHCP client has failed to renew its lease or  acquire  a  new
       one,  and  the  lease  has  expired.    The  IP  address  must be
       relinquished, and all related parameters should be deleted, as in
       RENEW and REBIND.

FAIL
       The DHCP client has been unable to contact any DHCP servers,  and
       any  leases  that  have  been tested have not proved to be valid.
       The parameters from the last lease tested should be deconfigured.
       This can be handled in the same way as EXPIRE.

The removal is probably correct for EXPIRE (because there was a lease
and it is no longer valid), but not for FAIL, as if I understand
correctly, there has never been any valid lease. I'm wondering what
"The parameters from the last lease tested should be deconfigured."
means; if any, I assume that this does not concern the NTP server.

-- 
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)



More information about the Pkg-systemd-maintainers mailing list