Re: Re: NetworkManager dispatcher script(20-chrony) not working on systemd-networkd

Miroslav Lichvar <[email protected]> Mon, 3 Aug 2026 17:08:37 +0200
Newsgroups gmane.comp.time.chrony.user
Message-ID <anCu9TbHw5AW0WNh@localhost>
--y+F7sgtPBf2a7wAb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Sat, Jul 25, 2026 at 03:47:22PM +1000, Cooper wrote:
> Reopening an old thread from 2023:
> https://www.mail-archive.com/[email protected]/msg03268.html
> 
> chrony: NTP sources left permanently offline after transient network
> loss (networkd-dispatcher hook runs before the interface is usable; no
> configured.d symlink)

Thanks for the details logs and analysis (with help of an agent?).

Can you please try the attached script and see if it works as expected
for you? It matches both the operational and admin states to avoid the
race condition and also adds the no-carrier state. Maybe it should
also handle the failed state?

-- 
Miroslav Lichvar

--y+F7sgtPBf2a7wAb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=chrony.networkd-dispatcher

#!/bin/sh
# This is a networkd-dispatcher script for chronyd to set its NTP sources
# online or offline when a network interface is configured or removed. It
# should be installed in the off.d, no-carrier.d, routable.d, and configured.d
# directories.

export LC_ALL=C

chronyc=/usr/bin/chronyc

# Consider only selected states
case "$OperationalState:$AdministrativeState" in
    routable:configured)
        ;;
    no-carrier:*|off:*)
        ;;
    *:*)
        exit 0;;
esac

$chronyc onoffline > /dev/null 2>&1

exit 0

--y+F7sgtPBf2a7wAb--


-- 
To unsubscribe email chrony-users-request-kWFZVVI9zxvPqho9SqqRMmD2FQJk+8+b@public.gmane.org 
with "unsubscribe" in the subject.
For help email chrony-users-request-kWFZVVI9zxvPqho9SqqRMmD2FQJk+8+b@public.gmane.org 
with "help" in the subject.
Trouble?  Email [email protected]