top of page

Chronyd: The Replacement for NTP in Rocky9/RHEL9


chrony

The chronyd service is a modern replacement for the ntpd (Network Time Protocol daemon) service in many Linux distributions. While ntpd has been the traditional choice for time synchronization, chronyd offers several advantages and improvements over its predecessor:


Chronyc Configuration

The main configuration file of chronyd is /etc/chrony.conf. Let's now understand the default enabled parameters of /etc/chrony.conf.

[root@siddhesh ~]$ cat /etc/chrony.conf |egrep -v '^#|^$'
pool 2.rocky.pool.ntp.org iburst
sourcedir /run/chrony-dhcp
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
keyfile /etc/chrony.keys
ntsdumpdir /var/lib/chrony
leapsectz right/UTC
logdir /var/log/chrony
server 169.254.169.123 prefer iburst minpoll 4 maxpoll 4
[root@siddhesh ~]$

pool 2.rocky.pool.ntp.org iburst: This line configures chronyd to use the NTP pool servers provided by 2.rocky.pool.ntp.org for time synchronization. The iburst option indicates that chronyd should send a burst of packets to the server when initially synchronizing.

sourcedir /run/chrony-dhcp: Specifies the directory where chronyd stores the temporary files related to DHCP-based time synchronization. These files contain information obtained from DHCP servers.

driftfile /var/lib/chrony/drift: Specifies the file where chronyd stores the estimated clock drift rate of the system clock. This information is used to adjust the clock frequency to keep it synchronized with the reference time sources.


makestep 1.0 3: Specifies the maximum allowed step adjustment for the system clock in seconds. If the time offset exceeds this value, chronyd will step the system clock rather than gradually adjust it. The second parameter (3) specifies the number of updates that must be consistent before chronyd steps the clock.


rtcsync: Enables synchronization of the hardware real-time clock (RTC) with the system clock. This ensures that the RTC maintains accurate time even when the system is powered off.


keyfile /etc/chrony.keys: Specifies the file where chronyd stores the symmetric keys used for NTP authentication. These keys are used to verify the authenticity of time synchronization messages exchanged with other NTP servers.


ntsdumpdir /var/lib/chrony: Specifies the directory where chronyd stores the dump files containing information about the state of the NTP sources and measurements. These files are used for troubleshooting and debugging purposes.


leapsectz right/UTC: Specifies the time zone information for handling leap seconds. In this case, it sets the time zone to UTC (Coordinated Universal Time) and adjusts for leap seconds according to the "right" timezone.


logdir /var/log/chrony: Specifies the directory where chronyd stores log files. Log files contain information about the operation of the chronyd service, including synchronization status and error messages.


server 169.254.169.123 prefer iburst minpoll 4 maxpoll 4: Configures chronyd to use the specified NTP server at IP address 169.254.169.123 as the preferred time source. The iburst option is used to initiate a burst of packets for faster initial synchronization. The minpoll and maxpoll options set the minimum and maximum polling intervals, respectively, to 16 seconds.


Chronyc Tracking

The chronyc tracking command displays parameters about the system’s clock performance. An example of the output is shown below.

[root@siddhesh ~]$ chronyc tracking
Reference ID    : A9FEA97B (169.254.169.123)
Stratum         : 4
Ref time (UTC)  : Fri Apr 19 10:00:50 2024
System time     : 0.000006250 seconds slow of NTP time
Last offset     : -0.000006760 seconds
RMS offset      : 0.000025910 seconds
Frequency       : 2.028 ppm slow
Residual freq   : +0.010 ppm
Skew            : 1.351 ppm
Root delay      : 0.000335780 seconds
Root dispersion : 0.000235377 seconds
Update interval : 16.3 seconds
Leap status     : Normal
[root@siddhesh ~]$

Here's an explanation of each line:

Reference ID - Identifies the NTP server to which your system is synchronized. In this case, the reference ID is "A9FEA97B" with the associated IP address "(169.254.169.123)".

Stratum - Indicates the stratum level of your system. The stratum represents the distance from the primary reference clock (stratum 0). A lower stratum number indicates a closer connection to the primary reference clock. Here, the stratum is 4.

Ref time (UTC) - Specifies the reference time in Coordinated Universal Time (UTC). This is the time obtained from the NTP server your system is synchronized with. In this case, it's "Fri Apr 19 10:00:50 2024".

System time - Shows the offset between your system's clock and the NTP time. Here, the system time is "0.000006250 seconds" slow compared to the NTP time.

Last offset - Indicates the last measured offset between your system's clock and the NTP time. Here, the last offset was "-0.000006760 seconds".

RMS offset - Root Mean Square (RMS) of the recent offset measurements. It gives an indication of the average error between your system's clock and the NTP time. Here, it's "0.000025910 seconds".

Frequency - Indicates the frequency error of your system's clock compared to the NTP time. A positive value means your clock is running slower than the NTP time. Here, it's "2.028 ppm slow" (parts per million).

Residual freq - Shows the residual frequency error of your system's clock after correction. Here, it's "+0.010 ppm".

Skew - Indicates the skew rate of your system's clock relative to the NTP time. Here, it's "1.351 ppm".

Root delay - Represents the total round-trip delay to the primary reference clock in seconds. Here, it's "0.000335780 seconds".

Root dispersion - Reflects the estimated error in the synchronization process in seconds. Here, it's "0.000235377 seconds".

Update interval - Specifies the interval between updates from the NTP server. Here, it's "16.3 seconds".

Leap status - Indicates the leap second status of the NTP server. "Normal" means there are no impending leap second events.


Chronyc Sources

The chronyc sources command displays information about the current time sources that chronyd is accessing.

If the -a option is specified, all sources are displayed, including those that do not have a known address yet. Such sources have an identifier in the format ID#XXXXXXXXXX, which can be used in other commands expecting a source address.

The -v option enables a verbose output. In this case, extra caption lines are shown as a reminder of the meanings of the columns.

[root@siddhesh ~]$ chronyc sources -a -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
===============================================================================
^- 164.100.255.123               2  10   377   29m    -16ms[  -17ms] +/-   66ms
^- 139.59.15.185                 3  10   377   242  +1955us[+1877us] +/-   15ms
^- 144.24.146.96                 2  10   375   253  -1400us[-1453us] +/-  172ms
^- ntp.qntmnet.com               2   9   377   428  -2370us[-2480us] +/-   80ms
^* 169.254.169.123               3   4   377     9  -2172ns[  -26us] +/-  357us
[root@siddhesh ~]$

Let's break down the output:


Source Mode: Indicates the mode of the NTP source. Here, '^' denotes a server.

Source State: Indicates the state of the source, with '*' indicating the current best source.

Reachability Register: Represents the reachability of the source in octal format.

Log2(Polling Interval): Indicates the polling interval for the source.

LastRx: Time since the last packet was received from the source.

Last Sample: Offset and error estimates for the last sample.


Chronyc Sourcestats

The chronyc sourcestats command displays information about the drift rate and offset estimation process for each of the sources currently being examined by chronyd.

[rocky@siddhesh ~]$ chronyc sourcestats -a -v
                             .- Number of sample points in measurement set.
                            /    .- Number of residual runs with same sign.
                           |    /    .- Length of measurement set (time).
                           |   |    /      .- Est. clock freq error (ppm).
                           |   |   |      /           .- Est. error in freq.
                           |   |   |     |           /         .- Est. offset.
                           |   |   |     |          |          |  
On the -.
                           |   |   |     |          |          |   samples. \
                           |   |   |     |          |          |             |
Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev
==============================================================================
164.100.255.123            16   9  258m     +0.103      0.709    -20ms  2867us
139.59.15.185              17  12  275m     +0.567      0.216  +1995us  1194us
144.24.146.96               6   3  103m     -0.260      0.885    -30us   421us
ntp.qntmnet.com            12   8   86m     +0.291      0.073  -2445us    89us
169.254.169.123             6   3    81     -0.525      1.259  -4687ns  8346ns
[rocky@siddhesh ~]$

Let's break down the columns and analyze the above output:

Name/IP Address: The IP address or hostname of the NTP source.

NP (Number of Sample Points): The number of sample points in the measurement set, indicating the quantity of data used for analysis.

NR (Number of Residual Runs): The number of residual runs with the same sign, which helps in assessing the consistency of the measurements.

Span: The length of the measurement set in time, indicating the duration over which the measurements were taken.

Frequency: The estimated clock frequency error in parts per million (ppm), showing how much the system clock differs from the reference time.

Freq Skew (Frequency Skew): The estimated error in frequency, indicating the variation in the clock frequency over time.

Offset: The estimated offset of the clock, showing the difference between the system time and the reference time.

Std Dev (Standard Deviation): The standard deviation of the offset, indicating the variability or precision of the measurements.


Chronyc Activity

The command chronyc activity reports the number of servers and peers that are online and offline.

[root@siddhesh ~]$ chronyc activity
200 OK
5 sources online
0 sources offline
0 sources doing burst (return to online)
0 sources doing burst (return to offline)
0 sources with unknown address
[root@siddhesh ~]$

200 OK: This indicates that the command was successful and that the chronyd service is functioning properly.

5 sources online: This tells us that there are currently 5 NTP sources that the system is actively synchronized with. These sources are providing accurate time information to the system.

0 sources offline: This indicates that none of the NTP sources are currently offline. All configured sources are reachable and providing synchronization data.

0 sources doing burst (return to online): This line indicates that there are no NTP sources that were previously offline and are now returning to the online state after a burst of activity.

0 sources doing burst (return to offline): Similarly, this line indicates that there are no NTP sources that were previously online and are now returning to the offline state after a burst of activity.

0 sources with unknown address: This final line indicates that there are no NTP sources with unknown or unrecognized addresses. All configured sources are properly identified and reachable.


Chronyc Ntpdata

The chronyc ntpdata command displays the last valid measurement and other NTP-specific information about the specified NTP source.

[root@siddhesh ~]# chronyc ntpdata
Remote address  : 169.254.169.123 (A9FEA97B)
Remote port     : 123
Local address   : 172.32.1.120 (AC200178)
Leap status     : Normal
Version         : 4
Mode            : Server
Stratum         : 3
Poll interval   : 4 (16 seconds)
Precision       : -18 (0.000003815 seconds)
Root delay      : 0.000137 seconds
Root dispersion : 0.000122 seconds
Reference ID    : A9FEA97A ()
Reference time  : Sat Apr 20 06:22:33 2024
Offset          : +0.000641089 seconds
Peer delay      : 0.001527276 seconds
Peer dispersion : 0.000003841 seconds
Response time   : 0.000018975 seconds
Jitter asymmetry: +0.00
NTP tests       : 111 111 1101
Interleaved     : No
Authenticated   : No
TX timestamping : Kernel
RX timestamping : Kernel
Total TX        : 13472
Total RX        : 13471
Total valid RX  : 13471
Total good RX   : 10337
[root@siddhesh ~]#

Chronyc Clients

This command shows a list of clients that have accessed the server.

[root@siddhesh ~]# chronyc  clients
Hostname                      NTP   Drop Int IntL Last     Cmd   Drop Int  Last
===============================================================================
localhost                       0      0   -   -     -      57      0  12   582
[root@siddhesh ~]#

Let's break down the columns and analyze the above output:


Hostname: This displays the hostname of the client that has made NTP requests to the server. In your output, localhost indicates the server itself is making requests, likely for synchronization purposes or self-checks.

NTP: Shows the number of NTP requests received from the client. In your case, it’s 0 for localhost, meaning no NTP requests have been received from localhost.

Drop: Indicates the number of NTP requests from the client that have been dropped due to some reason, like network issues or buffer overflows. Here, it’s 0, which means no requests were dropped.

Int (Interval): This column typically shows the minimum interval between requests from this client in seconds. A hyphen (-) indicates that there's no fixed interval, possibly because no requests have been made.

IntL (Interval Limit): Similar to Int but it typically would indicate a limit set for intervals between requests. Again, a hyphen (-) shows no limit is set or relevant due to the absence of requests.

Last: Time in seconds since the last NTP request was received from this client. A hyphen (-) signifies no requests have been received recently.

Cmd: Indicates the number of command requests (like your chronyc clients command) received from this client. 57 indicates that the localhost has sent 57 such command requests.

Drop: Similar to the NTP Drop column but pertains to command requests. Here it’s 0, indicating none of the command requests were dropped.

Int (Interval): Shows the minimum interval between command requests from this client. 12 seconds is the minimum interval observed between commands from localhost.

Last: Time in seconds since the last command request was received from this client. 582 seconds have elapsed since the last command was received from localhost.


Chronyc Serverstats

The chronyc serverstats command displays how many valid NTP and command requests chronyd as a server received from clients.

[root@siddhesh ~]# chronyc  serverstats
NTP packets received       : 0
NTP packets dropped        : 0
Command packets received   : 433
Command packets dropped    : 0
Client log records dropped : 0
NTS-KE connections accepted: 0
NTS-KE connections dropped : 0
Authenticated NTP packets  : 0
Interleaved NTP packets    : 0
NTP timestamps held        : 0
NTP timestamp span         : 0
[root@siddhesh ~]#

NTP packets received: 0 (No NTP packets have been received, indicating no active NTP synchronization.)

NTP packets dropped: 0 (No NTP packets have been dropped, which is expected given none were received.)

Command packets received: 433 (The server has received several command packets, showing it is responding to management commands.)

Command packets dropped: 0 (No command packets have been dropped, indicating good command handling.)

Client log records dropped: 0 (No client logs have been dropped.)

NTS-KE connections accepted/dropped: 0/0 (No NTS-KE secure connections have been made, possibly not configured or used.)

Authenticated NTP packets: 0 (No authenticated packets, likely due to no NTP activity or configuration.)

Interleaved NTP packets: 0 (No interleaved packets, suggesting simple configuration or lack of NTP activity.)

NTP timestamps held/span: 0/0 (No NTP timestamps are being held, consistent with no NTP packet processing.)


Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page