10.2. Synchronizing Clocks
NTP synchronization does one thing: it compares the local clock against one or more time servers and adjusts - by slewing small differences (gradually speeding up or slowing the clock) or stepping large ones (jumping the clock once) - until the two agree, then keeps them agreed. Servers are organized in strata: a stratum 1 server has a reference clock, and each client downstream is one stratum higher than its server. Debian 13 offers several implementations; this section compares them, walks a full client/server pair across the two example systems, and then breaks the pair deliberately to practice diagnosis.
10.2.1. Selecting a Time Synchronization Service
| Service | Debian 13 package | Serves time? | Runtime control | Fits |
|---|---|---|---|---|
| chrony | chrony 4.6.1-3+deb13u2 | Yes, full NTP server | chronyc monitoring and control commands |
Servers, clients with variable connectivity, systems needing observability |
| systemd-timesyncd | systemd-timesyncd 257.13-1~deb13u1 | No, SNTP client only | timedatectl timesync-status |
Simple always-on clients; minimal footprint and configuration |
| ntpsec | ntpsec 1.2.3+dfsg1-8 | Yes | ntpq-style tools |
Traditional NTP deployments migrating classic configurations |
| openntpd | openntpd 1:6.2p3-4.2+b2 | Yes | ntpd control socket |
Minimal designs accepting its constrained feature set |
ntpsec and openntpd are available in the archive but are not covered further here; they are listed because migrating sites ask for them. The practical choice is usually between the first two, and Figure 10.2 summarizes it.
Figure 10.2. Conceptual selection flow. The decisive questions are whether the system must serve time (or survive variable connectivity) and, if not, whether the smallest built-in client is enough.
One rule makes the choice concrete: only one time daemon may own the
system clock at a time. On Debian, chrony and systemd-timesyncd both
provide the system time-daemon, so installing one removes the other
- apt install systemd-timesyncd on a chrony system takes chrony out
with it, and vice versa. The two example systems ended up on opposite
sides, and their package states show both directions. On clock, as
john:
$ dpkg -l chrony systemd-timesyncd
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=================-================-============-===============================================================
ii chrony 4.6.1-3+deb13u2 amd64 Versatile implementation of the Network Time Protocol
rc systemd-timesyncd 257.13-1~deb13u1 amd64 minimalistic service to synchronize local time with NTP servers
ii is installed; rc means removed, with configuration files left
behind. On simple the states are mirrored:
$ dpkg -l chrony systemd-timesyncd
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=================-================-============-===============================================================
rc chrony 4.6.1-3+deb13u1 amd64 Versatile implementation of the Network Time Protocol
ii systemd-timesyncd 257.13-1~deb13u1 amd64 minimalistic service to synchronize local time with NTP servers
simple reached that state by installing systemd-timesyncd, which removed chrony in the same transaction. chrony is what a standard Debian 13 installation sets up; switching to timesyncd (or back) is a one-package change with an automatic removal, not a migration project.
10.2.2. Configuring a Simple Client with systemd-timesyncd
The examples in this subsection run on simple, as john unless a block
shows sudo. timesyncd is configured by /etc/systemd/timesyncd.conf
plus drop-ins under /etc/systemd/timesyncd.conf.d/ - the same drop-in
mechanism Chapter 8 used for unit files. First
look at the running state, which out of the box uses the Debian NTP
pool:
$ timedatectl timesync-status
Server: 216.128.178.20 (0.debian.pool.ntp.org)
Poll interval: 2min 8s (min: 32s; max 34min 8s)
Leap: normal
Version: 4
Stratum: 2
Reference: E0FAD6B5
Precision: 1us (-24)
Root distance: 21.895ms (max: 5s)
Offset: -1.878ms
Delay: 42.971ms
Jitter: 709us
Packet count: 2
Frequency: +1.702ppm
Read the fields the way a diagnosis will need them later: Server is
the currently contacted server with the pool name it came from;
Stratum: 2 is that server's stratum; Offset is the local clock's
error against it; Delay is the round-trip; Packet count counts
exchange packets since the service started - a live counter, not a
flag; and Poll interval adapts between its documented bounds as the
clock proves stable. The vendor configuration file shows where the
defaults live:
$ cat /etc/systemd/timesyncd.conf
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 2.1 of the License, or (at your option)
# any later version.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file (or a copy of it placed in
# /etc/ if the original file is shipped in /usr/), or by creating "drop-ins" in
# the /etc/systemd/timesyncd.conf.d/ directory. The latter is generally
# recommended. Defaults can be restored by simply deleting the main
# configuration file and all drop-ins located in /etc/.
#
# Use 'systemd-analyze cat-config systemd/timesyncd.conf' to display the full config.
#
# See timesyncd.conf(5) for details.
[Time]
#NTP=
#FallbackNTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org
#RootDistanceMaxSec=5
#PollIntervalMinSec=32
#PollIntervalMaxSec=2048
#ConnectionRetrySec=30
#SaveIntervalSec=60
timesyncd.conf setting |
Description |
|---|---|
NTP= |
Space-separated list of servers to use. |
FallbackNTP= |
Servers used when the NTP= list fails; the Debian pool by default. Setting it empty disables the fallback. |
RootDistanceMaxSec= |
Maximum accumulated distance accepted for a server. |
PollIntervalMinSec= / PollIntervalMaxSec= |
Bounds of the adaptive poll interval. |
To point simple at the chapter's own server instead, create the workspace and a drop-in source file. The drop-in is for simple only, and the address is a per-node value - clock's address on the lab network, replaced by your own server's:
$ mkdir -p ~/debian-handbook/timekeeping
Silent. The file's contents, saved as
~/debian-handbook/timekeeping/timesyncd-clock.conf:
[Time]
NTP=192.168.121.19
FallbackNTP=
The empty FallbackNTP= clears the Debian pool so the demonstration
has exactly one source - on a real system you may keep the pool as a
fallback. Install it as a drop-in and restart the service:
$ sudo install -d -m 755 /etc/systemd/timesyncd.conf.d
$ sudo install -m 644 /home/john/debian-handbook/timekeeping/timesyncd-clock.conf /etc/systemd/timesyncd.conf.d/50-handbook.conf
$ sudo systemctl restart systemd-timesyncd
All three print nothing. Check the new source:
$ timedatectl timesync-status
Server: 192.168.121.19 (192.168.121.19)
Poll interval: 1min 4s (min: 32s; max 34min 8s)
Leap: normal
Version: 4
Stratum: 3
Reference: C6327F48
Precision: 1us (-21)
Root distance: 38.474ms (max: 5s)
Offset: +108us
Delay: 8.220ms
Jitter: 0
Packet count: 1
Frequency: +2.544ppm
The server is now 192.168.121.19 at stratum 3 - clock is itself a client of internet servers at stratum 3, and serves that stratum downstream - the delay dropped from 43 ms to 8 ms across the local link, and the offset is a tenth of a millisecond. The journal records the switch:
$ sudo journalctl -u systemd-timesyncd --no-pager -n 6
Nov 19 23:54:56 simple systemd[1]: systemd-timesyncd.service: Deactivated successfully.
Nov 19 23:54:56 simple systemd[1]: Stopped systemd-timesyncd.service - Network Time Synchronization.
Nov 19 23:54:56 simple systemd[1]: Starting systemd-timesyncd.service - Network Time Synchronization...
Nov 19 23:54:56 simple systemd[1]: Started systemd-timesyncd.service - Network Time Synchronization.
Nov 19 23:54:56 simple systemd-timesyncd[7170]: Contacted time server 192.168.121.19:123 (192.168.121.19).
Nov 19 23:54:56 simple systemd-timesyncd[7170]: Initial clock synchronization to Thu 2026-11-19 23:54:56.214999 UTC.
The last two lines are the ones to remember: timesyncd logs each server it contacts and each initial synchronization. Section 10.2.4 shows the failure counterparts of both.
timesyncd is stopped and started through the same switch that controls
any time service, timedatectl set-ntp. Turn it off and back on to see
the property change both ways:
$ sudo timedatectl set-ntp false
$ timedatectl show -p NTP
NTP=no
$ sudo timedatectl set-ntp true
$ timedatectl show -p NTP
NTP=yes
Both set-ntp calls are silent; the show reads back the state they
set. That is the entire operational surface of timesyncd - a drop-in,
a restart, and timesync-status - which is precisely its appeal for a
simple always-on client. It cannot serve time to other systems, and it
offers no runtime monitoring beyond the panel just shown; both needs
point to chrony.
10.2.3. Using chrony for Servers and Variable Connectivity
Back on clock, as john unless a block says otherwise. The service is running here, and enabled to start at boot:
$ systemctl is-active chrony
active
$ systemctl is-enabled chrony
enabled
Its status tool is chronyc, and the two most important commands are
tracking (how disciplined is my clock?) and sources (who am I
synchronized to?):
$ chronyc tracking
Reference ID : 179F10C2 (ntp.netlinkify.com)
Stratum : 3
Ref time (UTC) : Thu Nov 19 23:54:07 2026
System time : 0.000000716 seconds slow of NTP time
Last offset : +0.000867051 seconds
RMS offset : 0.000867051 seconds
Frequency : 3.342 ppm fast
Residual freq : +30.895 ppm
Skew : 11.660 ppm
Root delay : 0.049799040 seconds
Root dispersion : 0.001147356 seconds
Update interval : 2.0 seconds
Leap status : Normal
Reference ID names the source currently combined into the clock;
System time is the live error (here sub-microsecond);
Frequency/Skew describe the local oscillator's rate correction and
its uncertainty; Update interval is the current poll spacing.
$ chronyc sources -v
.-- Source mode '^' = server, '=' = peer, '#' = local clock.
/ .- Source state '*' = current best, '+' = combined, '-' = not combined,
| / 'x' = may be in error, '~' = too variable, '?' = unusable.
|| .- xxxx [ yyyy ] +/- zzzz
|| Reachability register (octal) -. | xxxx = adjusted offset,
|| Log2(Polling interval) --. | | yyyy = measured offset,
|| \ | | zzzz = estimated error.
|| | | \
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^+ ntp.mtl2.ca.leaseweb.net 2 6 17 18 +3751us[+4618us] +/- 36ms
^- ip253.ip-142-4-192.net 2 6 17 18 +959us[+1826us] +/- 73ms
^* ntp.netlinkify.com 2 6 17 17 -2588us[-1721us] +/- 25ms
^- up2.com 2 6 17 17 +3593us[+4460us] +/- 110ms
-v prints the legend once, and it is worth reading in full - the same
legend explains every sources output in this chapter. The two
characters per row are the source mode and state:
| Marker | Meaning |
|---|---|
^ (mode) |
A server, polled client-to-server. |
* (state) |
Current best source; combined into the clock. |
+ (state) |
Combined with the best. |
- (state) |
Not combined. |
? (state) |
Unusable - unreachable, or not yet proven. |
x / ~ (state) |
Suspected error / too variable to trust. |
Reach is an octal shift register of the last eight poll attempts -
octal 17 (binary 001111) means the last four polls succeeded, and 377
means all eight - and Last sample shows the measured offset against
estimated error bounds. One row carries ^* - the best source the
tracking panel named - and the rest are combined or available
alternatives.
chronyc command |
Description |
|---|---|
tracking |
Current discipline state: reference, offset, frequency, leap status. |
sources [-v] |
List configured sources with mode/state markers. |
sourcestats |
Per-source drift and offset statistics. |
activity |
Counts of online, offline, and unknown sources. |
waitsync MAX TRIES |
Poll until synchronized; used in Section 10.1.2. |
makestep |
Step the clock now if the offset warrants it. |
offline / online |
Mark all sources offline/online at runtime. |
add server ADDR / delete ADDR |
Add or remove a source at runtime (not persistent). |
clients / serverstats |
Server-side: who is polling, and packet counters. |
Two companion views, condensed:
$ chronyc sourcestats
Name/IP Address NP NR Span Frequency Freq Skew Offset Std Dev
==============================================================================
ntp.mtl2.ca.leaseweb.net 4 3 6 +349.729 17408.578 +11ms 2448us
ip253.ip-142-4-192.net 4 3 6 -192.373 14219.736 -1713us 1432us
ntp.netlinkify.com 4 3 6 +29.847 997.864 -1986us 138us
up2.com 4 4 6 -25.651 559.399 +3096us 65us
$ chronyc activity
200 OK
4 sources online
0 sources offline
0 sources doing burst (return to online)
0 sources doing burst (return to offline)
0 sources with unknown address
sourcestats is the quality view - samples taken, span covered, rate
error, and offset scatter per source - consulted when deciding whether
a source is trustworthy; activity is the one-line summary.
Now make clock a server for its own network. chrony's main
configuration is /etc/chrony/chrony.conf, and Debian's packaged
configuration includes any *.conf file under /etc/chrony/conf.d/,
which is where local additions belong - the drop-in took effect on
this system through exactly that mechanism. Create
/etc/chrony/conf.d/handbook-lab.conf with these contents (the subnet
is a per-node value - use your own client subnet):
allow 192.168.121.0/24
local stratum 10
Two directives: allow opens the NTP port (123/udp) to the named
subnet so simple may poll; local stratum 10 enables the local
reference - if all upstream sources disappear, clock keeps serving
time at a poor-but-honest stratum 10 rather than going silent, so
local clients stay consistent even when the uplink is down. No third
directive is needed for the monitoring this chapter performs: chronyc
run as root reaches chronyd through its local Unix command socket,
and john's unprivileged calls fall back to UDP on the loopback
address, from which chronyd accepts monitoring commands by default
(cmdallow exists to extend that access to other hosts). In a root
shell on clock (sudo -i from john's shell; leave with exit),
create the directory, write the file, and restart the daemon:
# install -d -m 755 /etc/chrony/conf.d
# printf '%s\n' 'allow 192.168.121.0/24' 'local stratum 10' > /etc/chrony/conf.d/handbook-lab.conf
Both commands print nothing - the second is a redirection that writes
the file: printf emits its arguments and > sends them to
/etc/chrony/conf.d/handbook-lab.conf, so nothing appears on the
terminal, and the listing above is the file's contents. Restart and
confirm the daemon came back synchronized:
# systemctl restart chrony
The restart is silent as well; the confirmation is the waitsync below:
# chronyc waitsync 20 0.1
try: 1, refid: 7F7F0101, correction: 0.000000000, skew: 0.000
try: 2, refid: 8EA2AA8F, correction: 0.000002035, skew: 62.675
Leave the root shell with exit. simple has already been pointed at
this server in Section 10.2.2, so the pair is complete.
chrony's runtime commands make it possible to simulate connectivity problems without touching the network. Take all sources offline:
$ sudo chronyc offline
200 OK
Give it a few seconds to attempt a poll, then look at the source states:
$ chronyc sources
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^? ntp.mtl2.ca.leaseweb.net 2 6 0 30 +3751us[+4618us] +/- 36ms
^? ip253.ip-142-4-192.net 2 6 0 30 +959us[+1826us] +/- 73ms
^? ntp.netlinkify.com 2 6 0 29 -2588us[-1721us] +/- 25ms
^? up2.com 2 6 0 29 +3593us[+4460us] +/- 110ms
Every row is ^? - unusable - with Reach 0 because no poll
succeeds. This is precisely the picture a disconnected or firewalled
client shows. Bring them back:
$ sudo chronyc online
200 OK
Again, a few seconds for a poll to land:
$ chronyc sources
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* ntp.mtl2.ca.leaseweb.net 2 6 3 1 +7454us[+7783us] +/- 42ms
^+ ip253.ip-142-4-192.net 2 6 3 1 -1699us[-1699us] +/- 74ms
^+ ntp.netlinkify.com 2 6 3 1 -13ms[ -13ms] +/- 33ms
^- up2.com 2 6 3 1 +1687us[+1687us] +/- 110ms
The state markers recovered - ^* best, ^+ combined - and Reach 3
(binary 11) records the first two successful polls. makestep forces
an immediate step of the clock if the accumulated offset is large,
instead of waiting for the configured slew behavior; on this healthy
clock it has nothing to correct:
$ sudo chronyc makestep
200 OK
Finally, the server side of the pair - who is polling clock. The -n
option skips name resolution and shows client addresses as numbers:
$ sudo chronyc -n clients | head -n 5
Hostname NTP Drop Int IntL Last Cmd Drop Int Last
===============================================================================
127.0.0.1 0 0 - - - 28 0 0 46
192.168.121.207 3 0 4 - 6 0 0 - -
The interesting row is 192.168.121.207 - simple - which has sent three NTP packets, none dropped, matching the exchanges timesyncd made after each restart in Section 10.2.2. The loopback row is the local chronyc command traffic of this very section. The aggregate counters:
$ sudo chronyc serverstats | head -n 5
NTP packets received : 3
NTP packets dropped : 0
Command packets received : 38
Command packets dropped : 0
Client log records dropped : 0
Three NTP packets received, none dropped; the command-packet count is
the local chronyc traffic this section generated. Together clients
and serverstats answer the server-side questions - is my client
reaching me, and am I dropping its packets - that timesyncd has no way
to ask.
10.2.4. Verifying Synchronization and Diagnosing Unreachable Sources
The trap in clock diagnosis is the flag semantics established in
Section 10.1.2: System clock synchronized: yes records that
synchronization happened at least once. It does not prove the
configured source is reachable now - a client whose server vanished an
hour ago still shows the flag until its clock drifts perceptibly. The
reliable checks are the packet counter and the service's own log.
Break the pair on purpose. On simple, as john: replace the working
drop-in with one that names a dead address - 192.0.2.10 is from
TEST-NET-1, the documentation-only range, so nothing will ever answer.
The file's contents, saved as
~/debian-handbook/timekeeping/timesyncd-unreachable.conf:
[Time]
NTP=192.0.2.10
FallbackNTP=
Install it over the working drop-in and restart:
$ sudo rm -f /etc/systemd/timesyncd.conf.d/50-handbook.conf
$ sudo install -m 644 /home/john/debian-handbook/timekeeping/timesyncd-unreachable.conf /etc/systemd/timesyncd.conf.d/50-unreachable.conf
$ sudo systemctl restart systemd-timesyncd
All three are silent. After about ten seconds - the time the service waits for a reply - the status panel tells the truth even though the summary flag does not:
$ timedatectl timesync-status
Server: 192.0.2.10 (192.0.2.10)
Poll interval: 1min 4s (min: 32s; max 34min 8s)
Packet count: 0
The panel is short because nothing else is known: the server field
shows the configured address, and Packet count: 0 means not one
successful exchange since the restart - contrast with the healthy
counts in Section 10.2.2. The journal names the failure directly:
$ sudo journalctl -u systemd-timesyncd --no-pager -n 4
Nov 19 23:55:08 simple systemd[1]: Stopped systemd-timesyncd.service - Network Time Synchronization.
Nov 19 23:55:08 simple systemd[1]: Starting systemd-timesyncd.service - Network Time Synchronization...
Nov 19 23:55:08 simple systemd[1]: Started systemd-timesyncd.service - Network Time Synchronization.
Nov 19 23:55:18 simple systemd-timesyncd[7351]: Timed out waiting for reply from 192.0.2.10:123 (192.0.2.10).
Timed out waiting for reply is the definitive line: the request went
out, nothing came back. Restore the working drop-in and restart:
$ sudo rm -f /etc/systemd/timesyncd.conf.d/50-unreachable.conf
$ sudo install -m 644 /home/john/debian-handbook/timekeeping/timesyncd-clock.conf /etc/systemd/timesyncd.conf.d/50-handbook.conf
$ sudo systemctl restart systemd-timesyncd
Silent again; timedatectl timesync-status would show 192.168.121.19
with a rising packet count, as in Section 10.2.2.
The chrony equivalent of the same fault, on clock. Add the dead address as a runtime source (runtime additions do not survive a restart - a permanent source belongs in the configuration):
$ sudo chronyc add server 192.0.2.10
200 OK
Give it a few seconds, then check the source states:
$ chronyc sources
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* ntp.mtl2.ca.leaseweb.net 2 6 17 3 +3770us[+2037us] +/- 36ms
^+ ip253.ip-142-4-192.net 2 6 17 1 +3119us[+3119us] +/- 71ms
^+ ntp.netlinkify.com 2 6 17 3 -2841us[-2841us] +/- 25ms
^- up2.com 2 6 17 5 +3421us[+1687us] +/- 110ms
^? 192.0.2.10 0 6 0 - +0ns[ +0ns] +/- 0ns
The new row is the whole lesson: ^? unusable, stratum 0 (never
answered), Reach 0, and a zero sample. The other four sources remain
healthy - chrony keeps serving from them. Remove the dead source:
$ sudo chronyc delete 192.0.2.10
200 OK
That is the diagnostic method in miniature, and it generalizes beyond a deliberately dead address:
- Read the client counters -
timesync-status'sPacket count, or theReachcolumn ofchronyc sources. Zero means no working exchange. - Read the service journal -
Timed out waiting for reply(timesyncd) or all-question source states (chrony) is a connectivity symptom. - Only then inspect the network path - routing, firewalling, and DNS are Chapter 17's toolkit; NTP is UDP port 123 in both directions.
- On the server side,
chronyc clientsandserverstatsconfirm whether requests are arriving at all.
One interface note: timedatectl timesync-status works only with
systemd-timesyncd, because it reads the D-Bus interface that service
provides. On a chrony system it fails with The name
org.freedesktop.timesync1 was not provided by any .service files -
that failure is expected, not a fault; use chronyc tracking and
chronyc sources there instead.