NTP-Zeitserver mit chrony unter Linux einrichten und nutzen
Basis für eine zuverlässige Kommunikation zwischen netzwerkbasierten Diensten und Servern ist unter anderem eine exakte Zeitmessung. Nur so kann gewährleistet werden das Systemkomponenten wie z.B. systemd-Timer und Cronjobs zur richtigen Zeit gestartet werden und laufen. Einzelne Systeme können mit Hilfe des Network Time Protocol kurz NTP ihre Systemzeiten mit einem zentralen Zeitserver oder einem Pool von Servern zu synchronisieren. NTP wurde 1985 von David L. Mills entwickelt und wurde als RFC 958 definiert um eine zuverlässige Zeitgabe über Netzwerke mit variabler Paketlaufzeit über das verbindungslose Protokolls UDP zu ermöglichen und bekam von der Internet Assigned Numbers Authority den UDP-Ports 123 zugewiesen. Das RFC958 wurde in den letzten Jahren mehrfach überarbeitet und ergänzt und wurde letztmalig mit RFC 9109 - Network Time Protocol Version 4: Port Randomization ergänzt.
Weitere Hinweise findet man zum Thema NTP im sehr guten und ausführlichem WIKIPEDIA-Artikel. Eine Gegenüberstellung zu verschiedenen NTP-Implementierungen finden sich auf der folgenden chrony Projektseite Vergleich von NTP-Implementierungen.
In diesem Artikel wollen wir uns eingehender damit beschäftigen, wie wir zum einen mit Unterstützung des Chrony (NTP-Client) mit einem Chrony-Server (NTP-Daemon) synchronisieren können. In beiden Konfigurationsfällen greifen wir auf das Projekt chrony zurück.
Installation
Die einschlägigen Distributionen stellen für das Projekt chrony entsprechende Pakete bereit. Zur Installation bemühen wir den zugehörigen Paketmanager.
Chrony auf einem Fedora/RHEL Basierendem System installieren
Hier verwenden wir in aktuellen Versionen den Paketmanager dnf
und in älteren Versionen den Paketmanager yum
.
- Als User:
$ sudo ndf install chrony -y
bzw.
$ sudo yum install chrony -y
- Als Nutzer mit Root-Rechten entsprechend:
$ ndf install chrony -y
bzw.
$ yum install chrony -y
Chrony auf einem Debian/Ubuntu Basierendem System installieren
Hier verwenden wir das gewohnte Advanced Packaging Tool apt
.
- Als User:
$ sudo apt install chrony -y
- Als Nutzer mit Root-Rechten entsprechend:
$ sudo apt install chrony -y
Chrony auf einem (open)SuSE Basierendem System installieren
Hier verwenden wir das gewohnte Paketmanager Zypper zypper
.
- Als User:
$ sudo zypper install chrony -y
- Als Nutzer mit Root-Rechten entsprechend:
$ sudo zypper install chrony -y
Chrony unter Arch Linux installieren
Bei der Installation des chrony-Paketes verwenden wir unter Arch Linux den Paketmanager pacman
.
- Als User:
$ sudo pacman -S chrony
- Als Nutzer mit Root-Rechten entsprechend:
# pacman -S chrony
Paketinhalt
Was uns das Paket chrony alles in das System unseres Arch Linux Hosts gebracht hat, können wir wie folgt abfragen:
# pacman -Qil chrony
chronyc und chronyd
Nach der Installation des chrony Paketes finden wir zwei Binärpakete in unserem System.
# ll -alF /usr/bin/chrony*
-rwxr-xr-x 1 root root 88928 Dec 24 08:56 /usr/bin/chronyc* -rwxr-xr-x 1 root root 297640 Dec 24 08:56 /usr/bin/chronyd*
Binary chronyc
chronyc
ist das Commandline-Interface des chrony Daemon. chronyc
ist ein Kommandozeilen-Interface-Programm, mit dem die Leistung des chronyd überwacht werden und mit dem man bei Bedarf während der Laufzeit verschiedene Betriebsparameter abändern kann.
Die wichtigsten Parameter die beim Aufruf des Befehls mitgegeben werden können, kann man sich mit der Option –help
anzeigen lassen.
$ chronyc --help
Usage: chronyc [OPTION]... [COMMAND]...
Options:
-4 Use IPv4 addresses only
-6 Use IPv6 addresses only
-n Don't resolve hostnames
-N Print original source names
-c Enable CSV format
-e End responses with dot
-m Accept multiple commands
-h HOST Specify server (/var/run/chrony/chronyd.sock,127.0.0.1,::1)
-p PORT Specify UDP port (323)
-v, --version Print version and exit
--help Print usage and exit
Manualpage von chronyc
Binary chronyd
chronyd
ist der Daemon von chrony der dasfür sorgt, dass der chrony-Dienst während des Neustarts gestartet und somit aktiviert wird.
Wie schon beim Commandline-Interface chronyc
können wir uns auch hier die wichtigsten Optionen die beim Aufruf des Befehls mitgegeben werden können mit der Option –help
zur Anzeige gebracht werden.
$ chronyd --help
Usage: chronyd [OPTION]... [DIRECTIVE]... Options: -4 Use IPv4 addresses only -6 Use IPv6 addresses only -f FILE Specify configuration file (/etc/chrony.conf) -n Don't run as daemon -d Don't run as daemon and log to stderr -l FILE Log to file -L LEVEL Set logging threshold (0) -p Print configuration and exit -q Set clock and exit -Q Log offset and exit -r Reload dump files -R Adapt configuration for restart -s Set clock from RTC -t SECONDS Exit after elapsed time -u USER Specify user (chrony) -U Don't check for root -F LEVEL Set system call filter level (0) -P PRIORITY Set process priority (0) -m Lock memory -x Don't control clock -v, --version Print version and exit -h, --help Print usage and exit
Manualpage von chronyd
Eine ausführliche Beschreibung des Daemon und seiner Optionen findet man in zugehöriger Manual-Page.
$ man chronyd
Dokumentation
Eine ausführliche Onlinedokumentation des Chrony Projekts findet sich auf der entsprechenden Projektseite → https://chrony-project.org/documentation.html Bei der Installation des aktuellen chrony-Paketes z.B. unter Arch Linux finden sich im Verzeichnis /usr/share/doc/chrony/
auch entsprechende FAQs, READMEs, NEWS und Beispiele.
# tree /usr/share/doc/chrony/
/usr/share/doc/chrony// ├── examples/ │ ├── chrony.conf.example1 │ ├── chrony.conf.example2 │ ├── chrony.conf.example3 │ ├── chronyd-restricted.service │ ├── chronyd.service │ ├── chrony.keys.example │ ├── chrony.logrotate │ ├── chrony.nm-dispatcher.dhcp │ ├── chrony.nm-dispatcher.onoffline │ └── chrony-wait.service ├── chronyc.html ├── chrony.conf.html ├── chronyd.html ├── FAQ ├── faq.html ├── installation.html ├── NEWS └── README
FAQ
Zum Öffnen der im WIKI abgelegten FAQ-Page auf die grauen Balken klicken!
$ less /usr/share/doc/chrony/FAQ
Frequently Asked Questions Table of Contents o 1. chrony compared to other programs ? 1.1. How does chrony compare to ntpd? ? 1.2. Should I prefer chrony over timesyncd if I do not need to run a server? o 2. Configuration issues ? 2.1. What is the minimum recommended configuration for an NTP client? ? 2.2. How do I make an NTP server? ? 2.3. Should all computers on a LAN be clients of an external server? ? 2.4. Must I specify servers by IP address if DNS is not available on chronyd start? ? 2.5. How can I make chronyd more secure? ? 2.6. How can I make the system clock more secure? ? 2.7. How can I improve the accuracy of the system clock with NTP sources? ? 2.8. Does chronyd have an ntpdate mode? ? 2.9. Can chronyd be configured to control the clock like ntpd? ? 2.10. Can NTP server be separated from NTP client? ? 2.11. How can chronyd be configured to minimise downtime during restarts? ? 2.12. Should be a leap smear enabled on NTP server? ? 2.13. How should chronyd be configured with gpsd? ? 2.14. Does chrony support PTP? ? 2.15. How can I avoid using wrong PHC refclock? ? 2.16. Why are client log records dropped before reaching clientloglimit? ? 2.17. What happened to the commandkey and generatecommandkey directives? o 3. Computer is not synchronising ? 3.1. Behind a firewall? ? 3.2. Are NTP servers specified with the offline option? ? 3.3. Is name resolution working correctly? ? 3.4. Is chronyd allowed to step the system clock? ? 3.5. Using NTS? ? 3.6. Using a Windows NTP server? ? 3.7. An unreachable source is selected? ? 3.8. Does selected source drop new measurements? ? 3.9. Using a PPS reference clock? o 4. Issues with chronyc ? 4.1. I keep getting the error 506 Cannot talk to daemon ? 4.2. I keep getting the error 501 Not authorised ? 4.3. What is the reference ID reported by the tracking command? ? 4.4. Is the chronyc / chronyd protocol documented anywhere? o 5. Real-time clock issues ? 5.1. What is the real-time clock (RTC)? ? 5.2. Does hwclock have to be disabled? ? 5.3. I just keep getting the 513 RTC driver not running message ? 5.4. I get Could not open /dev/rtc, Device or resource busy in my syslog file ? 5.5. When I start chronyd, the log says Could not enable RTC interrupt : Invalid argument (or it may say disable) ? 5.6. What if my computer does not have an RTC or backup battery? o 6. NTP-specific issues ? 6.1. Can chronyd be driven from broadcast/multicast NTP servers? ? 6.2. Can chronyd transmit broadcast NTP packets? ? 6.3. Can chronyd keep the system clock a fixed offset away from real time? ? 6.4. What happens if the network connection is dropped without using chronyc's offline command first? ? 6.5. Why is an offset measured between two computers synchronised to each another? o 7. Operation ? 7.1. What clocks does chronyd use? o 8. Operating systems ? 8.1. Does chrony support Windows? ? 8.2. Are there any plans to support Windows? 1. chrony compared to other programs 1.1. How does chrony compare to ntpd? chrony and ntpd are two different implementations of the Network Time Protocol (NTP). chrony is a newer implementation, which was designed to work well in a wider range of conditions. It can usually synchronise the system clock faster and with better time accuracy. It has many features, but it does not implement some of the less useful NTP modes like broadcast client or multicast server/client. If your computer is connected to the Internet only for few minutes at a time, the network connection is often congested, you turn your computer off or suspend it frequently, the clock is not very stable (e.g. there are rapid changes in the temperature or it is a virtual machine), or you want to use NTP on an isolated network with no hardware reference clocks in sight, chrony will probably work better for you. For a more detailed comparison of features and performance, see the comparison page on the chrony website. 1.2. Should I prefer chrony over timesyncd if I do not need to run a server? Generally, yes. systemd-timesyncd is a very simple NTP client included in the systemd suite. It lacks almost all features of chrony and other advanced client implementations listed on the comparison page. One of its main limitations is that it cannot poll multiple servers at the same time and detect servers having incorrect time (falsetickers in the NTP terminology). It should be used only with trusted reliable servers, ideally in local network. Using timesyncd with pool.ntp.org is problematic. The pool is very robust as a whole, but the individual servers run by volunteers cannot be relied on. Occasionally, servers drift away or make a step to distant past or future due to misconfiguration, problematic implementation, and other bugs (e.g. in firmware of a GPS receiver). The pool monitoring system detects such servers and quickly removes them from the pool DNS, but clients like timesyncd cannot recover from that. They follow the server as long as it claims to be synchronised. They need to be restarted in order to get a new address from the pool DNS. Note that the complexity of NTP and clock synchronisation is on the client side. The amount of code in chrony specific to NTP server is very small and it is disabled by default. If it was removed, it would not significantly reduce the amount of memory or storage needed. 2. Configuration issues 2.1. What is the minimum recommended configuration for an NTP client? First, the client needs to know which NTP servers it should ask for the current time. They are specified by the server or pool directive. The pool directive is used with names that resolve to multiple addresses of different servers. For reliable operation, the client should have at least three servers. The iburst option enables a burst of requests to speed up the initial synchronisation. To stabilise the initial synchronisation on the next start, the estimated drift of the system clock is saved to a file specified by the driftfile directive. If the system clock can be far from the true time after boot for any reason, chronyd should be allowed to correct it quickly by stepping instead of slewing, which would take a very long time. The makestep directive does that. In order to keep the real-time clock (RTC) close to the true time, so the system time is reasonably close to the true time when it is initialised on the next boot from the RTC, the rtcsync directive enables a mode in which the system time is periodically copied to the RTC. It is supported on Linux and macOS. If you wanted to use public NTP servers from the pool.ntp.org project, the minimal chrony.conf file could be: pool pool.ntp.org iburst driftfile /var/lib/chrony/drift makestep 1 3 rtcsync 2.2. How do I make an NTP server? By default, chronyd does not operate as an NTP server. You need to add an allow directive to the chrony.conf file in order for chronyd to open the server NTP port and respond to client requests. allow 192.168.1.0/24 An allow directive with no specified subnet allows access from all IPv4 and IPv6 addresses. 2.3. Should all computers on a LAN be clients of an external server? It depends on the requirements. Usually, the best configuration is to make one computer the server, with the others as clients of it. Add a local directive to the server's chrony.conf file. This configuration will be better because o the load on the external connection is less o the load on the external NTP server(s) is less o if your external connection goes down, the computers on the LAN will maintain a common time with each other. 2.4. Must I specify servers by IP address if DNS is not available on chronyd start? No, chronyd will keep trying to resolve the names specified by the server, pool, and peer directives in an increasing interval until it succeeds. The online command can be issued from chronyc to force chronyd to try to resolve the names immediately. 2.5. How can I make chronyd more secure? If you do not need to use chronyc, or you want to run chronyc only under the root or chrony user (which can access chronyd through a Unix domain socket), you can disable the IPv4 and IPv6 command sockets (by default listening on localhost) by adding cmdport 0 to the configuration file. You can specify an unprivileged user with the -u option, or the user directive in the chrony.conf file, to which chronyd will switch after start in order to drop root privileges. The configure script has a --with-user option, which sets the default user. On Linux, chronyd needs to be compiled with support for the libcap library. On other systems, chronyd forks into two processes. The child process retains root privileges, but can only perform a very limited range of privileged system calls on behalf of the parent. Also, if chronyd is compiled with support for the Linux secure computing (seccomp) facility, you can enable a system call filter with the -F option. It will significantly reduce the kernel attack surface and possibly prevent kernel exploits from the chronyd process if it is compromised. It is recommended to enable the filter only when it is known to work on the version of the system where chrony is installed as the filter needs to allow also system calls made from libraries that chronyd is using (e.g. libc) and different versions or implementations of the libraries might make different system calls. If the filter is missing some system call, chronyd could be killed even in normal operation. 2.6. How can I make the system clock more secure? An NTP client synchronising the system clock to an NTP server is susceptible to various attacks, which can break applications and network protocols relying on accuracy of the clock (e.g. DNSSEC, Kerberos, TLS, WireGuard). Generally, a man-in-the-middle (MITM) attacker between the client and server can o make fake responses, or modify real responses from the server, to create an arbitrarily large time and frequency offset, make the server appear more accurate, insert a leap second, etc. o delay the requests and/or responses to create a limited time offset and temporarily also a limited frequency offset o drop the requests or responses to prevent updates of the clock with new measurements o redirect the requests to a different server The attacks can be combined for a greater effect. The attacker can delay packets to create a significant frequency offset first and then drop all subsequent packets to let the clock quickly drift away from the true time. The attacker might also be able to control the server's clock. Some attacks cannot be prevented. Monitoring is needed for detection, e.g. the reachability register in the sources report shows missing packets. The extent to which the attacker can control the client's clock depends on its configuration. Enable authentication to prevent chronyd from accepting modified, fake, or redirected packets. It can be enabled with a symmetric key specified by the key option, or Network Time Security (NTS) by the nts option (supported since chrony version 4.0). The server needs to support the selected authentication mechanism. Symmetric keys have to be configured on both client and server, and each client must have its own key (one per server). The maximum offset that the attacker can insert in an NTP measurement by delaying packets can be limited by the maxdelay option. The default value is 3 seconds. The measured delay is reported as the peer delay in the ntpdata report and measurements log. Set the maxdelay option to a value larger than the maximum value that is normally observed. Note that the delay can increase significantly even when not under an attack, e.g. when the network is congested or the routing has changed. The maximum accepted change in time offset between clock updates can be limited by the maxchange directive. Larger changes in the offset will be ignored or cause chronyd to exit. Note that the attacker can get around this limit by splitting the offset into multiple smaller offsets and/or creating a large frequency offset. When this directive is used, chronyd will have to be restarted after a successful attack. It will not be able to recover on its own. It must not be restarted automatically (e.g. by the service manager). The impact of a large accepted time offset can be reduced by disabling clock steps, i.e. by not using the makestep and initstepslew directives. The offset will be slowly corrected by speeding up or slowing down the clock at a rate which can be limited by the maxslewrate directive. Disabling clock steps completely is practical only if the clock cannot gain a larger error on its own, e.g. when the computer is shut down or suspended, and the maxslewrate limit is large enough to correct an expected error in an acceptable time. The rtcfile directive with the -s option can be used to compensate for the RTC drift. A more practical approach is to enable makestep for a limited number of clock updates (the 2nd argument of the directive) and limit the offset change in all updates by the maxchange directive. The attacker will be able to make only a limited step and only if the attack starts in a short window after booting the computer, or when chronyd is restarted without the -R option. The frequency offset can be limited by the maxdrift directive. The measured frequency offset is reported in the drift file, tracking report, and tracking log. Set maxdrift to a value larger than the maximum absolute value that is normally observed. Note that the frequency of the clock can change due to aging of the crystal, differences in calibration of the clock source between reboots, migrated virtual machine, etc. A typical computer clock has a drift smaller than 100 parts per million (ppm), but much larger drifts are possible (e.g. in some virtual machines). Use only trusted servers, which you expect to be well configured and managed, using authentication for their own servers, etc. Use multiple servers, ideally in different locations. The attacker will have to deal with a majority of the servers in order to pass the source selection and update the clock with a large offset. Use the minsources directive to increase the required number of selectable sources to make the selection more robust. Do not specify servers as peers. The symmetric mode is less secure than the client/server mode. If not authenticated, it is vulnerable to off-path denial-of-service attacks, and even when it is authenticated, it is still susceptible to replay attacks. Mixing of authenticated and unauthenticated servers should generally be avoided. If mixing is necessary (e.g. for a more accurate and stable synchronisation to a closer server which does not support authentication), the authenticated servers should be configured as trusted and required to not allow the unauthenticated servers to override the authenticated servers in the source selection. Since chrony version 4.0, the selection options are enabled in such a case automatically. This behaviour can be disabled or modified by the authselectmode directive. An example of a client configuration limiting the impact of the attacks could be server ntp1.example.net iburst nts maxdelay 0.1 server ntp2.example.net iburst nts maxdelay 0.2 server ntp3.example.net iburst nts maxdelay 0.05 server ntp4.example.net iburst nts maxdelay 0.1 server ntp5.example.net iburst nts maxdelay 0.1 minsources 3 maxchange 100 0 0 makestep 0.001 1 maxdrift 100 maxslewrate 100 driftfile /var/lib/chrony/drift ntsdumpdir /var/lib/chrony rtcsync 2.7. How can I improve the accuracy of the system clock with NTP sources? Select NTP servers that are well synchronised, stable and close to your network. It is better to use more than one server. Three or four is usually recommended as the minimum, so chronyd can detect servers that serve false time and combine measurements from multiple sources. If you have a network card with hardware timestamping supported on Linux, it can be enabled by the hwtimestamp directive. It should make local receive and transmit timestamps of NTP packets much more stable and accurate. The server directive has some useful options: minpoll, maxpoll, polltarget, maxdelay, maxdelayratio, maxdelaydevratio, xleave, filter. The first three options set the minimum and maximum allowed polling interval, and how should be the actual interval adjusted in the specified range. Their default values are 6 (64 seconds) for minpoll, 10 (1024 seconds) for maxpoll and 8 (samples) for polltarget. The default values should be used for general servers on the Internet. With your own NTP servers, or if you have permission to poll some servers more frequently, setting these options for shorter polling intervals might significantly improve the accuracy of the system clock. The optimal polling interval depends mainly on two factors, stability of the network latency and stability of the system clock (which mainly depends on the temperature sensitivity of the crystal oscillator and the maximum rate of the temperature change). Generally, if the sourcestats command usually reports a small number of samples retained for a source (e.g. fewer than 16), a shorter polling interval should be considered. If the number of samples is usually at the maximum of 64, a longer polling interval might work better. An example of the directive for an NTP server on the Internet that you are allowed to poll frequently could be server ntp.example.net minpoll 4 maxpoll 6 polltarget 16 An example using shorter polling intervals with a server located in the same LAN could be server ntp.local minpoll 2 maxpoll 4 polltarget 30 The maxdelay options are useful to ignore measurements with an unusually large delay (e.g. due to congestion in the network) and improve the stability of the synchronisation. The maxdelaydevratio option could be added to the example with local NTP server server ntp.local minpoll 2 maxpoll 4 polltarget 30 maxdelaydevratio 2 If your server supports the interleaved mode (e.g. it is running chronyd), the xleave option should be added to the server directive to enable the server to provide the client with more accurate transmit timestamps (kernel or preferably hardware). For example: server ntp.local minpoll 2 maxpoll 4 xleave When combined with local hardware timestamping, good network switches, and even shorter polling intervals, a sub-microsecond accuracy and stability of a few tens of nanoseconds might be possible. For example: server ntp.local minpoll 0 maxpoll 0 xleave hwtimestamp eth0 For best stability, the CPU should be running at a constant frequency (i.e. disabled power saving and performance boosting). Energy-Efficient Ethernet (EEE) should be disabled in the network. The switches should be configured to prioritize NTP packets, especially if the network is expected to be heavily loaded. The dscp directive can be used to set the Differentiated Services Code Point in transmitted NTP packets if needed. If it is acceptable for NTP clients in the network to send requests at a high rate, a sub-second polling interval can be specified. A median filter can be enabled in order to update the clock at a reduced rate with more stable measurements. For example: server ntp.local minpoll -6 maxpoll -6 filter 15 xleave hwtimestamp eth0 minpoll -6 Since chrony version 4.3, the minimum minpoll is -7 and a filter using a long-term estimate of a delay quantile can be enabled by the maxdelayquant option to replace the default maxdelaydevratio filter, which is sensitive to outliers corrupting the minimum delay. For example: server ntp.local minpoll -7 maxpoll -7 filter 31 maxdelayquant 0.3 xleave Since version 4.2, chronyd supports an NTPv4 extension field containing an additional timestamp to enable frequency transfer and significantly improve stability of synchronisation. It can be enabled by the extfield F323 option. For example: server ntp.local minpoll 0 maxpoll 0 xleave extfield F323 Since version 4.5, chronyd can apply corrections from PTP one-step end-to-end transparent clocks (e.g. network switches) to significantly improve accuracy of synchronisation in local networks. It requires the PTP transport to be enabled by the ptpport directive, HW timestamping, and the extfield F324 option. For example: server ntp.local minpoll -4 maxpoll -4 xleave extfield F323 extfield F324 port 319 ptpport 319 hwtimestamp eth0 minpoll -4 2.8. Does chronyd have an ntpdate mode? Yes. With the -q option chronyd will set the system clock once and exit. With the -Q option it will print the measured offset without setting the clock. If you do not want to use a configuration file, NTP servers can be specified on the command line. For example: # chronyd -q 'pool pool.ntp.org iburst' The command above would normally take about 5 seconds if the servers were well synchronised and responding to all requests. If not synchronised or responding, it would take about 10 seconds for chronyd to give up and exit with a non-zero status. A faster configuration is possible. A single server can be used instead of four servers, the number of measurements can be reduced with the maxsamples option to one (supported since chrony version 4.0), and a timeout can be specified with the -t option. The following command would take only up to about one second. # chronyd -q -t 1 'server pool.ntp.org iburst maxsamples 1' It is not recommended to run chronyd with the -q option periodically (e.g. from a cron job) as a replacement for the daemon mode, because it performs significantly worse (e.g. the clock is stepped and its frequency is not corrected). If you must run it this way and you are using a public NTP server, make sure chronyd does not always start around the first second of a minute, e.g. by adding a random sleep before the chronyd command. Public servers typically receive large bursts of requests around the first second as there is a large number of NTP clients started from cron with no delay. 2.9. Can chronyd be configured to control the clock like ntpd? It is not possible to perfectly emulate ntpd, but there are some options that can configure chronyd to behave more like ntpd if there is a reason to prefer that. In the following example the minsamples directive slows down the response to changes in the frequency and offset of the clock. The maxslewrate and corrtimeratio directives reduce the maximum frequency error due to an offset correction and the maxdrift directive reduces the maximum assumed frequency error of the clock. The makestep directive enables a step threshold and the maxchange directive enables a panic threshold. The maxclockerror directive increases the minimum dispersion rate. minsamples 32 maxslewrate 500 corrtimeratio 100 maxdrift 500 makestep 0.128 -1 maxchange 1000 1 1 maxclockerror 15 Note that increasing minsamples might cause the offsets in the tracking and sourcestats reports/logs to be significantly smaller than the actual offsets and be unsuitable for monitoring. 2.10. Can NTP server be separated from NTP client? Yes, it is possible to run multiple instances of chronyd on a computer at the same time. One can operate primarily as an NTP client to synchronise the system clock and another as a server for other computers. If they use the same filesystem, they need to be configured with different pidfiles, Unix domain command sockets, and any other file or directory specified in the configuration file. If they run in the same network namespace, they need to use different NTP and command ports, or bind the ports to different addresses or interfaces. The server instance should be started with the -x option to prevent it from adjusting the system clock and interfering with the client instance. It can be configured as a client to synchronise its NTP clock to other servers, or the client instance running on the same computer. In the latter case, the copy option (added in chrony version 4.1) can be used to assume the reference ID and stratum of the client instance, which enables detection of synchronisation loops with its own clients. On Linux, starting with chrony version 4.0, it is possible to run multiple server instances sharing a port to better utilise multiple cores of the CPU. Note that for rate limiting and client/server interleaved mode to work well it is necessary that all packets received from the same address are handled by the same server instance. An example configuration of the client instance could be pool pool.ntp.org iburst allow 127.0.0.1 port 11123 driftfile /var/lib/chrony/drift makestep 1 3 rtcsync and configuration of the first server instance could be server 127.0.0.1 port 11123 minpoll 0 maxpoll 0 copy allow cmdport 11323 bindcmdaddress /var/run/chrony/chronyd-server1.sock pidfile /var/run/chronyd-server1.pid driftfile /var/lib/chrony/drift-server1 2.11. How can chronyd be configured to minimise downtime during restarts? The dumpdir directive in chrony.conf provides chronyd a location to save a measurement history of the sources it uses when the service exits. The -r option then enables chronyd to load state from the dump files, reducing the synchronisation time after a restart. Similarly, the ntsdumpdir directive provides a location for chronyd to save NTS cookies received from the server to avoid making a NTS-KE request when chronyd is started. When operating as an NTS server, chronyd also saves cookies keys to this directory to allow clients to continue to use the old keys after a server restart for a more seamless experience. On Linux systems, systemd socket activation provides a mechanism to reuse server sockets across chronyd restarts, so that client requests will be buffered until the service is again able to handle the requests. This allows for zero-downtime service restarts, simplified dependency logic at boot, and on-demand service spawning (for instance, for separated server chronyd instances run with the -x flag). Socket activation is supported since chrony version 4.5. The service manager (systemd) creates sockets and passes file descriptors to them to the process via the LISTEN_FDS environment variable. Before opening new sockets, chronyd first checks for and attempts to reuse matching sockets passed from the service manager. For instance, if an IPv4 datagram socket bound on bindaddress and port is available, it will be used by the NTP server to accept incoming IPv4 requests. An example systemd socket unit is below, where chronyd is configured with bindaddress 0.0.0.0, bindaddress ::, port 123, and ntsport 4460. [Unit] Description=chronyd server sockets [Socket] Service=chronyd.service # IPv4 NTP server ListenDatagram=0.0.0.0:123 # IPv6 NTP server ListenDatagram=[::]:123 # IPv4 NTS-KE server ListenStream=0.0.0.0:4460 # IPv6 NTS-KE server ListenStream=[::]:4460 BindIPv6Only=ipv6-only [Install] WantedBy=sockets.target 2.12. Should be a leap smear enabled on NTP server? With the smoothtime and leapsecmode directives it is possible to enable a server leap smear in order to hide leap seconds from clients and force them to follow a slow server's adjustment instead. This feature should be used only in local networks and only when necessary, e.g. when the clients cannot be configured to handle the leap seconds as needed, or their number is so large that configuring them all would be impractical. The clients should use only one leap-smearing server, or multiple identically configured leap-smearing servers. Note that some clients can get leap seconds from other sources (e.g. with the leapsectz directive in chrony) and they will not work correctly with a leap smearing server. 2.13. How should chronyd be configured with gpsd? A GPS or other GNSS receiver can be used as a reference clock with gpsd. It can work as one or two separate time sources for each connected receiver. The first time source is based on timestamping of messages sent by the receiver. Typically, it is accurate to milliseconds. The other source is much more accurate. It is timestamping a pulse-per-second (PPS) signal, usually connected to a serial port (e.g. DCD pin) or GPIO pin. If the PPS signal is connected to the serial port which is receiving messages from the GPS/GNSS receiver, gpsd should detect and use it automatically. If it is connected to a GPIO pin, or another serial port, the PPS device needs to be specified on the command line as an additional data source. On Linux, the ldattach utility can be used to create a PPS device for a serial device. The PPS-based time source provided by gpsd is available as a SHM 1 refclock, or other odd number if gpsd is configured with multiple receivers, and also as SOCK /var/run/chrony.DEV.sock where DEV is the name of the serial device (e.g. ttyS0). The message-based time source is available as a SHM 0 refclock (or other even number) and since gpsd version 3.25 also as SOCK /var/run/chrony.clk.DEV.sock where DEV is the name of the serial device. The SOCK refclocks should be preferred over SHM for better security (the shared memory segment needs to be created by chronyd or gpsd with an expected owner and permissions before an untrusted application or user has a chance to create its own in order to feed chronyd with false measurements). gpsd needs to be started after chronyd in order to connect to the socket. With chronyd and gpsd both supporting PPS, there are two different recommended configurations: # First option refclock SOCK /var/run/chrony.ttyS0.sock refid GPS # Second option refclock PPS /dev/pps0 lock NMEA refid GPS refclock SOCK /var/run/chrony.clk.ttyS0.sock offset 0.5 delay 0.1 refid NMEA noselect They both have some advantages: o SOCK can be more accurate than PPS if gpsd corrects for the sawtooth error provided by the receiver in serial data o PPS can be used with higher PPS rates (specified by the rate option), but it requires a second refclock or another time source to pair pulses with seconds, and the SOCK offset needs to be specified correctly to compensate for the message delay, while gpsd can apply HW-specific information If the PPS signal is not available, or cannot be used for some reason, the only option is the message-based timing refclock SOCK /var/run/chrony.clk.ttyS0.sock offset 0.5 delay 0.1 refid GPS or the SHM equivalent if using gpsd version before 3.25 refclock SHM 0 offset 0.5 delay 0.1 refid GPS 2.14. Does chrony support PTP? No, the Precision Time Protocol (PTP) is not supported as a protocol for synchronisation of clocks and there are no plans to support it. It is a complex protocol, which shares some issues with the NTP broadcast mode. One of the main differences between NTP and PTP is that PTP was designed to be easily supported in hardware (e.g. network switches and routers) in order to make more stable and accurate measurements. PTP relies on the hardware support. NTP does not rely on any support in the hardware, but if it had the same support as PTP, it could perform equally well. On Linux, chrony supports hardware clocks that some NICs have for PTP. They are called PTP hardware clocks (PHC). They can be used as reference clocks (specified by the refclock directive) and for hardware timestamping of NTP packets (enabled by the hwtimestamp directive) if the NIC can timestamp other packets than PTP, which is usually the case at least for transmitted packets. The ethtool -T command can be used to verify the timestamping support. As an experimental feature added in version 4.2, chrony can use PTP as a transport for NTP messages (NTP over PTP) to enable hardware timestamping on hardware which can timestamp PTP packets only. It can be enabled by the ptpport directive. Since version 4.5, chrony can also apply corrections provided by PTP one-step end-to-end transparent clocks to reach the accuracy of ordinary PTP clocks. The application of PTP corrections can be enabled by the extfield F324 option. 2.15. How can I avoid using wrong PHC refclock? If your system has multiple PHC devices, normally named by udev as /dev/ptp0, / dev/ptp1, and so on, their order can change randomly across reboots depending on the order of initialisation of their drivers. If a PHC refclock is specified by this name, chronyd could be using a wrong refclock after reboot. To prevent that, you can configure udev to create a stable symlink for chronyd with a rule like this (e.g. written to /etc/udev/rules.d/80-phc.rules): KERNEL=="ptp[0-9]*", DEVPATH=="/devices/pci0000:00/0000:00:01.2/0000:02:00.0/ptp/*", SYMLINK+="ptp-i350-1" You can get the full DEVPATH of an existing PHC device with the udevadm info command. You will need to execute the udevadm trigger command, or reboot the system, for these changes to take effect. 2.16. Why are client log records dropped before reaching clientloglimit? The number of dropped client log records reported by the serverstats command can be increasing before the number of clients reported by the clients command reaches the maximum value corresponding to the memory limit set by the clientloglimit directive. This is due to the design of the data structure keeping the client records. It is a hash table which can store only up to 16 colliding addresses per slot. If a slot has more collisions and the table already has the maximum size, the oldest record will be dropped and replaced by the new client. Note that the size of the table is always a power of two and it can only grow. The limit set by the clientloglimit directive takes into account that two copies of the table exist when it is being resized. This means the actual memory usage reported by top and other utilities can be significantly smaller than the limit even when the maximum number of records is used. The absolute maximum number of client records kept at the same time is 16777216. 2.17. What happened to the commandkey and generatecommandkey directives? They were removed in version 2.2. Authentication is no longer supported in the command protocol. Commands that required authentication are now allowed only through a Unix domain socket, which is accessible only by the root and chrony users. If you need to configure chronyd remotely or locally without the root password, please consider using ssh and/or sudo to run chronyc under the root or chrony user on the host where chronyd is running. 3. Computer is not synchronising This is the most common problem. There are a number of reasons, see the following questions. 3.1. Behind a firewall? Check the Reach value printed by the chronyc's sources command. If it is zero, it means chronyd did not get any valid responses from the NTP server you are trying to use. If there is a firewall between you and the server, the requests sent to the UDP port 123 of the server or responses sent back from the port might be blocked. Try using a tool like wireshark or tcpdump to see if you are getting any responses from the server. When chronyd is receiving responses from the servers, the output of the sources command issued few minutes after chronyd start might look like this: MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^* ntp1.example.net 2 6 377 34 +484us[ -157us] +/- 30ms ^- ntp2.example.net 2 6 377 34 +33ms[ +32ms] +/- 47ms ^+ ntp3.example.net 3 6 377 35 -1397us[-2033us] +/- 60ms 3.2. Are NTP servers specified with the offline option? Check that the chronyc's online and offline commands are used appropriately (e.g. in the system networking scripts). The activity command prints the number of sources that are currently online and offline. For example: 200 OK 3 sources online 0 sources offline 0 sources doing burst (return to online) 0 sources doing burst (return to offline) 0 sources with unknown address 3.3. Is name resolution working correctly? NTP servers specified by their hostname (instead of an IP address) have to have their names resolved before chronyd can send any requests to them. If the activity command prints a non-zero number of sources with unknown address, there is an issue with the resolution. Typically, a DNS server is specified in /etc/resolv.conf. Make sure it is working correctly. Since chrony version 4.0, you can run chronyc -N sources -a command to print all sources, even those that do not have a known address yet, with their names as they were specified in the configuration. This can be useful to verify that the names specified in the configuration are used as expected. 3.4. Is chronyd allowed to step the system clock? By default, chronyd adjusts the clock gradually by slowing it down or speeding it up. If the clock is too far from the true time, it will take a long time to correct the error. The System time value printed by the chronyc's tracking command is the remaining correction that needs to be applied to the system clock. The makestep directive can be used to allow chronyd to step the clock. For example, if chrony.conf had makestep 1 3 the clock would be stepped in the first three updates if its offset was larger than one second. Normally, it is recommended to allow the step only in the first few updates, but in some cases (e.g. a computer without an RTC or virtual machine which can be suspended and resumed with an incorrect time) it might be necessary to allow the step on any clock update. The example above would change to makestep 1 -1 3.5. Using NTS? The Network Time Security (NTS) mechanism uses Transport Layer Security (TLS) to establish the keys needed for authentication of NTP packets. Run the authdata command to check whether the key establishment was successful: # chronyc -N authdata Name/IP address Mode KeyID Type KLen Last Atmp NAK Cook CLen ========================================================================= ntp1.example.net NTS 1 15 256 33m 0 0 8 100 ntp2.example.net NTS 1 15 256 33m 0 0 8 100 ntp3.example.net NTS 1 15 256 33m 0 0 8 100 The KeyID, Type, and KLen columns should have non-zero values. If they are zero, check the system log for error messages from chronyd. One possible cause of failure is a firewall blocking the client's connection to the server's TCP port 4460. Another possible cause of failure is a certificate that is failing to verify because the client's clock is wrong. This is a chicken-and-egg problem with NTS. You might need to manually correct the date, or temporarily disable NTS, in order to get NTS working. If your computer has an RTC and it is backed up by a good battery, this operation should be needed only once, assuming the RTC will be set periodically with the rtcsync directive, or compensated with the rtcfile directive and the -s option. If the computer does not have an RTC or battery, you can use the -s option without rtcfile directive to restore time of the last shutdown or reboot from the drift file. The clock will start behind the true time, but if the computer was not shut down for too long and the server's certificate was not renewed too close to its expiration, it should be sufficient for the time checks to succeed. If you run your own server, you can use a self-signed certificate covering all dates where the client can start (e.g. years 1970-2100). The certificate needs to be installed on the client and specified with the ntstrustedcerts directive. The server can have multiple names and certificates. To avoid trusting a certificate for too long, a new certificate can be added to the server periodically (e.g. once per year) and the client can have the server name and trusted certificate updated automatically (e.g. using a package repository, or a cron script downloading the files directly from the server over HTTPS). A client that was shut down for years will still be able to synchronise its clock and perform the update as long as the server keeps the old certificate. As a last resort, you can disable the time checks by the nocerttimecheck directive. This has some important security implications. To reduce the security risk, you can use the nosystemcert and ntstrustedcerts directives to disable the system's default trusted certificate authorities and trust only a minimal set of selected authorities needed to validate the certificates of used NTP servers. 3.6. Using a Windows NTP server? A common issue with Windows NTP servers is that they report a very large root dispersion (e.g. three seconds or more), which causes chronyd to ignore the server for being too inaccurate. The sources command might show a valid measurement, but the server is not selected for synchronisation. You can check the root dispersion of the server with the chronyc's ntpdata command. The maxdistance value needs to be increased in chrony.conf to enable synchronisation to such a server. For example: maxdistance 16.0 3.7. An unreachable source is selected? When chronyd is configured with multiple time sources, it tries to select the most accurate and stable sources for synchronisation of the system clock. They are marked with the * or + symbol in the report printed by the sources command. When the best source (marked with the * symbol) becomes unreachable (e.g. NTP server stops responding), chronyd will not immediately switch to the second best source in an attempt to minimise the error of the clock. It will let the clock run free for as long as its estimated error (in terms of root distance) based on previous measurements is smaller than the estimated error of the second source, and there is still an interval which contains some measurements from both sources. If the first source was significantly better than the second source, it can take many hours before the second source is selected, depending on its polling interval. You can force a faster reselection by increasing the clock error rate (maxclockerror directive), shortening the polling interval (maxpoll option), or reducing the number of samples (maxsamples option). 3.8. Does selected source drop new measurements? chronyd can drop a large number of successive NTP measurements if they are not passing some of the NTP tests. The sources command can report for a selected source the fully-reachable value of 377 in the Reach column and at the same time a LastRx value that is much larger than the current polling interval. If the source is online, this indicates that a number of measurements was dropped. You can use the ntpdata command to check the NTP tests for the last measurement. Usually, it is the test C which fails. This can be an issue when there is a long-lasting increase in the measured delay, e.g. due to a routing change in the network. Unfortunately, chronyd does not know for how long it should wait for the delay to come back to the original values, or whether it is a permanent increase and it should start from scratch. The test C is an adaptive filter. It can take many hours before it accepts a measurement with the larger delay, and even much longer before it drops all measurements with smaller delay, which determine an expected delay used by the test. You can use the reset sources command to drop all measurements immediately (available in chrony 4.0 and later). If this issue happens frequently, you can effectively disable the test by setting the maxdelaydevratio option to a very large value (e.g. 1000000), or speed up the recovery by increasing the clock error rate with the maxclockerror directive. 3.9. Using a PPS reference clock? A pulse-per-second (PPS) reference clock requires a non-PPS time source to determine which second of UTC corresponds to each pulse. If it is another reference clock specified with the lock option in the refclock directive, the offset between the two reference clocks must be smaller than 0.4 seconds (0.2 seconds with chrony versions before 4.1) in order for the PPS reference clock to work. With NMEA reference clocks it is common to have a larger offset. It needs to be corrected with the offset option. One approach to find out a good value of the offset option is to configure the reference clocks with the noselect option and compare them to an NTP server. For example, if the sourcestats command showed Name/IP Address NP NR Span Frequency Freq Skew Offset Std Dev ============================================================================== PPS0 0 0 0 +0.000 2000.000 +0ns 4000ms NMEA 58 30 231 -96.494 38.406 +504ms 6080us ntp1.example.net 7 3 200 -2.991 16.141 -107us 492us the offset of the NMEA source would need to be increased by about 0.504 seconds. It does not have to be very accurate. As long as the offset of the NMEA reference clock stays below the limit, the PPS reference clock should be able to determine the seconds corresponding to the pulses and allow the samples to be used for synchronisation. 4. Issues with chronyc 4.1. I keep getting the error 506 Cannot talk to daemon When accessing chronyd remotely, make sure that the chrony.conf file (on the computer where chronyd is running) has a cmdallow entry for the computer you are running chronyc on and an appropriate bindcmdaddress directive. This is not necessary for localhost. Perhaps chronyd is not running. Try using the ps command (e.g. on Linux, ps -auxw) to see if it is running. Or try netstat -a and see if the UDP port 323 is listening. If chronyd is not running, you might have a problem with the way you are trying to start it (e.g. at boot time). Perhaps you have a firewall set up in a way that blocks packets on the UDP port 323. You need to amend the firewall configuration in this case. 4.2. I keep getting the error 501 Not authorised This error indicates that chronyc sent the command to chronyd using a UDP socket instead of the Unix domain socket (e.g. /var/run/chrony/chronyd.sock), which is required for some commands. For security reasons, only the root and chrony users are allowed to access the socket. It is also possible that the socket does not exist. chronyd will not create the socket if the directory has a wrong owner or permissions. In this case there should be an error message from chronyd in the system log. 4.3. What is the reference ID reported by the tracking command? The reference ID is a 32-bit value used in NTP to prevent synchronisation loops. In chrony versions before 3.0 it was printed in the quad-dotted notation, even if the reference source did not actually have an IPv4 address. For IPv4 addresses, the reference ID is equal to the address, but for IPv6 addresses it is the first 32 bits of the MD5 sum of the address. For reference clocks, the reference ID is the value specified with the refid option in the refclock directive. Since version 3.0, the reference ID is printed as a hexadecimal number to avoid confusion with IPv4 addresses. If you need to get the IP address of the current reference source, use the -n option to disable resolving of IP addresses and read the second field (printed in parentheses) on the Reference ID line. 4.4. Is the chronyc / chronyd protocol documented anywhere? Only by the source code. See cmdmon.c (chronyd side) and client.c (chronyc side). Note that this protocol is not compatible with the mode 6 or mode 7 protocol supported by ntpd, i.e. the ntpq or ntpdc utility cannot be used to monitor chronyd, and chronyc cannot be used to monitor ntpd. 5. Real-time clock issues 5.1. What is the real-time clock (RTC)? This is the clock which keeps the time even when your computer is turned off. It is used to initialise the system clock on boot. It normally does not drift more than few seconds per day. There are two approaches how chronyd can work with it. One is to use the rtcsync directive, which tells chronyd to enable a kernel mode which sets the RTC from the system clock every 11 minutes. chronyd itself will not touch the RTC. If the computer is not turned off for a long time, the RTC should still be close to the true time when the system clock will be initialised from it on the next boot. The other option is to use the rtcfile directive, which tells chronyd to monitor the rate at which the RTC gains or loses time. When chronyd is started with the -s option on the next boot, it will set the system time from the RTC and also compensate for the drift it has measured previously. The rtcautotrim directive can be used to keep the RTC close to the true time, but it is not strictly necessary if its only purpose is to set the system clock when chronyd is started on boot. See the documentation for details. 5.2. Does hwclock have to be disabled? The hwclock program is run by default in the boot and/or shutdown scripts in some Linux installations. With the kernel RTC synchronisation (rtcsync directive), the RTC will be set also every 11 minutes as long as the system clock is synchronised. If you want to use chronyd's RTC monitoring (rtcfile directive), it is important to disable hwclock in the shutdown procedure. If you do not do that, it will overwrite the RTC with a new value, unknown to chronyd. At the next reboot, chronyd started with the -s option will compensate this (wrong) time with its estimate of how far the RTC has drifted whilst the power was off, giving a meaningless initial system time. There is no need to remove hwclock from the boot process, as long as chronyd is started after it has run. 5.3. I just keep getting the 513 RTC driver not running message For the real-time clock support to work, you need the following three things o an RTC in your computer o a Linux kernel with enabled RTC support o an rtcfile directive in your chrony.conf file 5.4. I get Could not open /dev/rtc, Device or resource busy in my syslog file Some other program running on the system might be using the device. 5.5. When I start chronyd, the log says Could not enable RTC interrupt : Invalid argument (or it may say disable) Your real-time clock hardware might not support the required ioctl requests: o RTC_UIE_ON o RTC_UIE_OFF A possible solution could be to build the Linux kernel with support for software emulation instead; try enabling the following configuration option when building the Linux kernel: o CONFIG_RTC_INTF_DEV_UIE_EMUL 5.6. What if my computer does not have an RTC or backup battery? In this case you can still use the -s option to set the system clock to the last modification time of the drift file, which should correspond to the system time when chronyd was previously stopped. The initial system time will be increasing across reboots and applications started after chronyd will not observe backward steps. 6. NTP-specific issues 6.1. Can chronyd be driven from broadcast/multicast NTP servers? No, the broadcast/multicast client mode is not supported and there is currently no plan to implement it. While this mode can simplify configuration of clients in large networks, it is inherently less accurate and less secure (even with authentication) than the ordinary client/server mode. When configuring a large number of clients in a network, it is recommended to use the pool directive with a DNS name which resolves to addresses of multiple NTP servers. The clients will automatically replace the servers when they become unreachable, or otherwise unsuitable for synchronisation, with new servers from the pool. Even with very modest hardware, an NTP server can serve time to hundreds of thousands of clients using the ordinary client/server mode. 6.2. Can chronyd transmit broadcast NTP packets? Yes, the broadcast directive can be used to enable the broadcast server mode to serve time to clients in the network which support the broadcast client mode (it is not supported in chronyd). Note that this mode should generally be avoided. See the previous question. 6.3. Can chronyd keep the system clock a fixed offset away from real time? Yes. Starting from version 3.0, an offset can be specified by the offset option for all time sources in the chrony.conf file. 6.4. What happens if the network connection is dropped without using chronyc's offline command first? chronyd will keep trying to access the sources that it thinks are online, and it will take longer before new measurements are actually made and the clock is corrected when the network is connected again. If the sources were set to offline, chronyd would make new measurements immediately after issuing the online command. Unless the network connection lasts only few minutes (less than the maximum polling interval), the delay is usually not a problem, and it might be acceptable to keep all sources online all the time. 6.5. Why is an offset measured between two computers synchronised to each another? When two computers are synchronised to each other using the client/server or symmetric NTP mode, there is an expectation that NTP measurements between the two computers made on both ends show an average offset close to zero. With chronyd that can be expected only when the interleaved mode is enabled by the xleave option. Otherwise, chronyd will use different transmit timestamps (e.g. daemon timestamp vs kernel timestamp) for serving time and synchronisation of its own clock, which will cause the other computer to measure a significant offset. 7. Operation 7.1. What clocks does chronyd use? There are several different clocks used by chronyd: o System clock: software clock maintained by the kernel. It is the main clock used by applications running on the computer. It is synchronised by chronyd to its NTP clock, unless started with the -x option. o NTP clock: software clock (virtual) based on the system clock and internal to chronyd. It keeps the best estimate of the true time according to the configured time sources, which is served to NTP clients unless time smoothing is enabled by the smoothtime directive. The System time value in the tracking report is the current offset between the system and NTP clock. o Real-time clock (RTC): hardware clock keeping time even when the computer is turned off. It is used by the kernel to initialise the system clock on boot and also by chronyd to compensate for its measured drift if configured with the rtcfile directive and started with the -s option. The clock can be kept accurate only by stepping enabled by the rtcsync or rtcautotrim directive. o Reference clock: hardware clock used as a time source. It is specified by the refclock directive. o NIC clock (also known as PTP hardware clock): hardware clock timestamping packets received and transmitted by a network device specified by the hwtimestamp directive. The clock is expected to be running free. It is not synchronised by chronyd. Its offset is tracked relative to the NTP clock in order to convert the hardware timestamps. 8. Operating systems 8.1. Does chrony support Windows? No. The chronyc program (the command-line client used for configuring chronyd while it is running) has been successfully built and run under Cygwin in the past. chronyd is not portable, because part of it is very system-dependent. It needs adapting to work with Windows' equivalent of the adjtimex() call, and it needs to be made to work as a service. 8.2. Are there any plans to support Windows? We have no plans to do this. Anyone is welcome to pick this work up and contribute it back to the project. Last updated 2023-12-05 14:22:10 +0100
NEWS
Zum Öffnen der im WIKI abgelegten NEWS-Page auf die grauen Balken klicken!
$ less /usr/share/doc/chrony/NEWS
New in version 4.5 ================== Enhancements ------------ * Add support for AES-GCM-SIV in GnuTLS * Add support for corrections from PTP transparent clocks * Add support for systemd socket activation Bug fixes --------- * Fix presend in interleaved mode * Fix reloading of modified sources from sourcedir New in version 4.4 ================== Enhancements ------------ * Add support for AES-GCM-SIV with Nettle >= 3.9 to shorten NTS cookies to avoid some length-specific blocking of NTP on Internet * Add support for multiple refclocks using extpps option on one PHC * Add maxpoll option to hwtimestamp directive to improve PHC tracking with low packet rates * Add hwtstimeout directive to configure timeout for late timestamps * Handle late hardware transmit timestamps of NTP requests on all sockets * Handle mismatched 32/64-bit time_t in SOCK refclock samples * Improve source replacement * Log important changes made by command requests (chronyc) * Refresh address of NTP sources periodically * Request nanosecond kernel RX timestamping on FreeBSD * Set DSCP for IPv6 packets * Shorten NTS-KE retry interval when network is down * Update seccomp filter for musl * Warn if loading keys from file with unexpected permissions * Warn if source selection fails or falseticker is detected * Add selectopts command to modify source-specific selection options * Add timestamp sources to serverstats report and make its fields 64-bit * Add -e option to chronyc to indicate end of response New in version 4.3 ================== Enhancements ------------ * Add local option to refclock directive to stabilise system clock with more stable free-running clock (e.g. TCXO, OCXO) * Add maxdelayquant option to server/pool/peer directive to replace maxdelaydevratio filter with long-term quantile-based filtering * Add selection option to log directive * Allow external PPS in PHC refclock without configurable pin * Don't accept first interleaved response to minimise error in delay * Don't use arc4random on Linux to avoid server performance loss * Improve filter option to better handle missing NTP samples * Improve stability with hardware timestamping and PHC refclock * Update seccomp filter Bug fixes --------- * Fix waitsync command to reconnect when not getting response New in version 4.2 ================== Enhancements ------------ * Add support for NTPv4 extension field improving synchronisation stability and resolution of root delay and dispersion (experimental) * Add support for NTP over PTP (experimental) * Add support for AES-CMAC and hash functions in GnuTLS * Improve server interleaved mode to be more reliable and support multiple clients behind NAT * Update seccomp filter * Add statistics about interleaved mode to serverstats report Bug fixes --------- * Fix RTC support with 64-bit time_t on 32-bit Linux * Fix seccomp filter to work correctly with bind*device directives * Suppress kernel adjustments of system clock (dosynctodr) on illumos Other changes ------------- * Switch Solaris support to illumos New in version 4.1 ================== Enhancements ------------ * Add support for NTS servers specified by IP address (matching Subject Alternative Name in server certificate) * Add source-specific configuration of trusted certificates * Allow multiple files and directories with trusted certificates * Allow multiple pairs of server keys and certificates * Add copy option to server/pool directive * Increase PPS lock limit to 40% of pulse interval * Perform source selection immediately after loading dump files * Reload dump files for addresses negotiated by NTS-KE server * Update seccomp filter and add less restrictive level * Restart ongoing name resolution on online command Bug fixes --------- * Fix responding to IPv4 command requests on FreeBSD * Fix dump files to not include uncorrected offset * Fix initstepslew to accept time from own NTP clients * Reset NTP address and port when no longer negotiated by NTS-KE server New in version 4.0 ================== Enhancements ------------ * Add support for Network Time Security (NTS) authentication * Add support for AES-CMAC keys (AES128, AES256) with Nettle * Add authselectmode directive to control selection of unauthenticated sources * Add binddevice, bindacqdevice, bindcmddevice directives * Add confdir directive to better support fragmented configuration * Add sourcedir directive and "reload sources" command to support dynamic NTP sources specified in files * Add clockprecision directive * Add dscp directive to set Differentiated Services Code Point (DSCP) * Add -L option to limit log messages by severity * Add -p option to print whole configuration with included files * Add -U option to allow start under non-root user * Allow maxsamples to be set to 1 for faster update with -q/-Q option * Avoid replacing NTP sources with sources that have unreachable address * Improve pools to repeat name resolution to get "maxsources" sources * Improve source selection with trusted sources * Improve NTP loop test to prevent synchronisation to itself * Repeat iburst when NTP source is switched from offline state to online * Update clock synchronisation status and leap status more frequently * Update seccomp filter * Add "add pool" command * Add "reset sources" command to drop all measurements * Add authdata command to print details about NTP authentication * Add selectdata command to print details about source selection * Add -N option and sourcename command to print original names of sources * Add -a option to some commands to print also unresolved sources * Add -k, -p, -r options to clients command to select, limit, reset data Bug fixes --------- * Don't set interface for NTP responses to allow asymmetric routing * Handle RTCs that don't support interrupts * Respond to command requests with correct address on multihomed hosts Removed features ---------------- * Drop support for RIPEMD keys (RMD128, RMD160, RMD256, RMD320) * Drop support for long (non-standard) MACs in NTPv4 packets (chrony 2.x clients using non-MD5/SHA1 keys need to use option "version 3") * Drop support for line editing with GNU Readline New in version 3.5.1 ==================== Security fixes -------------- * Create new file when writing pidfile (CVE-2020-14367) New in version 3.5 ================== Enhancements ------------ * Add support for more accurate reading of PHC on Linux 5.0 * Add support for hardware timestamping on interfaces with read-only timestamping configuration * Add support for memory locking and real-time priority on FreeBSD, NetBSD, Solaris * Update seccomp filter to work on more architectures * Validate refclock driver options Bug fixes --------- * Fix bindaddress directive on FreeBSD * Fix transposition of hardware RX timestamp on Linux 4.13 and later * Fix building on non-glibc systems New in version 3.4 ================== Enhancements ------------ * Add filter option to server/pool/peer directive * Add minsamples and maxsamples options to hwtimestamp directive * Add support for faster frequency adjustments in Linux 4.19 * Change default pidfile to /var/run/chrony/chronyd.pid to allow chronyd without root privileges to remove it on exit * Disable sub-second polling intervals for distant NTP sources * Extend range of supported sub-second polling intervals * Get/set IPv4 destination/source address of NTP packets on FreeBSD * Make burst options and command useful with short polling intervals * Modify auto_offline option to activate when sending request failed * Respond from interface that received NTP request if possible * Add onoffline command to switch between online and offline state according to current system network configuration * Improve example NetworkManager dispatcher script Bug fixes --------- * Avoid waiting in Linux getrandom system call * Fix PPS support on FreeBSD and NetBSD New in version 3.3 ================== Enhancements ------------ * Add burst option to server/pool directive * Add stratum and tai options to refclock directive * Add support for Nettle crypto library * Add workaround for missing kernel receive timestamps on Linux * Wait for late hardware transmit timestamps * Improve source selection with unreachable sources * Improve protection against replay attacks on symmetric mode * Allow PHC refclock to use socket in /var/run/chrony * Add shutdown command to stop chronyd * Simplify format of response to manual list command * Improve handling of unknown responses in chronyc Bug fixes --------- * Respond to NTPv1 client requests with zero mode * Fix -x option to not require CAP_SYS_TIME under non-root user * Fix acquisitionport directive to work with privilege separation * Fix handling of socket errors on Linux to avoid high CPU usage * Fix chronyc to not get stuck in infinite loop after clock step New in version 3.2 ================== Enhancements ------------ * Improve stability with NTP sources and reference clocks * Improve stability with hardware timestamping * Improve support for NTP interleaved modes * Control frequency of system clock on macOS 10.13 and later * Set TAI-UTC offset of system clock with leapsectz directive * Minimise data in client requests to improve privacy * Allow transmit-only hardware timestamping * Add support for new timestamping options introduced in Linux 4.13 * Add root delay, root dispersion and maximum error to tracking log * Add mindelay and asymmetry options to server/peer/pool directive * Add extpps option to PHC refclock to timestamp external PPS signal * Add pps option to refclock directive to treat any refclock as PPS * Add width option to refclock directive to filter wrong pulse edges * Add rxfilter option to hwtimestamp directive * Add -x option to disable control of system clock * Add -l option to log to specified file instead of syslog * Allow multiple command-line options to be specified together * Allow starting without root privileges with -Q option * Update seccomp filter for new glibc versions * Dump history on exit by default with dumpdir directive * Use hardening compiler options by default Bug fixes --------- * Don't drop PHC samples with low-resolution system clock * Ignore outliers in PHC tracking, RTC tracking, manual input * Increase polling interval when peer is not responding * Exit with error message when include directive fails * Don't allow slash after hostname in allow/deny directive/command * Try to connect to all addresses in chronyc before giving up New in version 3.1 ================== Enhancements ------------ * Add support for precise cross timestamping of PHC on Linux * Add minpoll, precision, nocrossts options to hwtimestamp directive * Add rawmeasurements option to log directive and modify measurements option to log only valid measurements from synchronised sources * Allow sub-second polling interval with NTP sources Bug fixes --------- * Fix time smoothing in interleaved mode New in version 3.0 ================== Enhancements ------------ * Add support for software and hardware timestamping on Linux * Add support for client/server and symmetric interleaved modes * Add support for MS-SNTP authentication in Samba * Add support for truncated MACs in NTPv4 packets * Estimate and correct for asymmetric network jitter * Increase default minsamples and polltarget to improve stability with very low jitter * Add maxjitter directive to limit source selection by jitter * Add offset option to server/pool/peer directive * Add maxlockage option to refclock directive * Add -t option to chronyd to exit after specified time * Add partial protection against replay attacks on symmetric mode * Don't reset polling interval when switching sources to online state * Allow rate limiting with very short intervals * Improve maximum server throughput on Linux and NetBSD * Remove dump files after start * Add tab-completion to chronyc with libedit/readline * Add ntpdata command to print details about NTP measurements * Allow all source options to be set in add server/peer command * Indicate truncated addresses/hostnames in chronyc output * Print reference IDs as hexadecimal numbers to avoid confusion with IPv4 addresses Bug fixes --------- * Fix crash with disabled asynchronous name resolving New in version 2.4.1 ==================== Bug fixes --------- * Fix processing of kernel timestamps on non-Linux systems * Fix crash with smoothtime directive * Fix validation of refclock sample times * Fix parsing of refclock directive New in version 2.4 ================== Enhancements ------------ * Add orphan option to local directive for orphan mode compatible with ntpd * Add distance option to local directive to set activation threshold (1 second by default) * Add maxdrift directive to set maximum allowed drift of system clock * Try to replace NTP sources exceeding maximum distance * Randomise source replacement to avoid getting stuck with bad sources * Randomise selection of sources from pools on start * Ignore reference timestamp as ntpd doesn't always set it correctly * Modify tracking report to use same values as seen by NTP clients * Add -c option to chronyc to write reports in CSV format * Provide detailed manual pages Bug fixes --------- * Fix SOCK refclock to work correctly when not specified as last refclock * Fix initstepslew and -q/-Q options to accept time from own NTP clients * Fix authentication with keys using 512-bit hash functions * Fix crash on exit when multiple signals are received * Fix conversion of very small floating-point numbers in command packets Removed features ---------------- * Drop documentation in Texinfo format New in version 2.3 ================== Enhancements ------------ * Add support for NTP and command response rate limiting * Add support for dropping root privileges on Mac OS X, FreeBSD, Solaris * Add require and trust options for source selection * Enable logchange by default (1 second threshold) * Set RTC on Mac OS X with rtcsync directive * Allow binding to NTP port after dropping root privileges on NetBSD * Drop CAP_NET_BIND_SERVICE capability on Linux when NTP port is disabled * Resolve names in separate process when seccomp filter is enabled * Replace old records in client log when memory limit is reached * Don't reveal local time and synchronisation state in client packets * Don't keep client sockets open for longer than necessary * Ignore poll in KoD RATE packets as ntpd doesn't always set it correctly * Warn when using keys shorter than 80 bits * Add keygen command to generate random keys easily * Add serverstats command to report NTP and command packet statistics Bug fixes --------- * Fix clock correction after making step on Mac OS X * Fix building on Solaris New in version 2.2.1 ==================== Security fixes -------------- * Restrict authentication of NTP server/peer to specified key (CVE-2016-1567) New in version 2.2 ================== Enhancements ------------ * Add support for configuration and monitoring over Unix domain socket (accessible by root or chrony user when root privileges are dropped) * Add support for system call filtering with seccomp on Linux (experimental) * Add support for dropping root privileges on NetBSD * Control frequency of system clock on FreeBSD, NetBSD, Solaris * Add system leap second handling mode on FreeBSD, NetBSD, Solaris * Add dynamic drift removal on Mac OS X * Add support for setting real-time priority on Mac OS X * Add maxdistance directive to limit source selection by root distance (3 seconds by default) * Add refresh command to get new addresses of NTP sources * Allow wildcard patterns in include directive * Restore time from driftfile with -s option if later than RTC time * Add configure option to set default hwclockfile * Add -d option to chronyc to enable debug messages * Allow multiple addresses to be specified for chronyc with -h option and reconnect when no valid reply is received * Make check interval in waitsync command configurable Bug fixes --------- * Fix building on NetBSD, Solaris * Restore time from driftfile with -s option if reading RTC failed Removed features ---------------- * Drop support for authentication with command key (run-time configuration is now allowed only for local users that can access the Unix domain socket) New in version 2.1.1 ==================== Bug fixes --------- * Fix clock stepping by integer number of seconds on Linux New in version 2.1 ================== Enhancements ------------ * Add support for Mac OS X * Try to replace unreachable and falseticker servers/peers specified by name like pool sources * Add leaponly option to smoothtime directive to allow synchronised leap smear between multiple servers * Use specific reference ID when smoothing served time * Add smoothing command to report time smoothing status * Add smoothtime command to activate or reset time smoothing Bug fixes --------- * Fix crash in source selection with preferred sources * Fix resetting of time smoothing * Include packet precision in peer dispersion * Fix crash in chronyc on invalid command syntax New in version 2.0 ================== Enhancements ------------ * Update to NTP version 4 (RFC 5905) * Add pool directive to specify pool of NTP servers * Add leapsecmode directive to select how to correct clock for leap second * Add smoothtime directive to smooth served time and enable leap smear * Add minsources directive to set required number of selectable sources * Add minsamples and maxsamples options for all sources * Add tempcomp configuration with list of points * Allow unlimited number of NTP sources, refclocks and keys * Allow unreachable sources to remain selected * Improve source selection * Handle offline sources as unreachable * Open NTP server port only when necessary (client access is allowed by allow directive/command or peer/broadcast is configured) * Change default bindcmdaddress to loopback address * Change default maxdelay to 3 seconds * Change default stratumweight to 0.001 * Update adjtimex synchronisation status * Use system headers for adjtimex * Check for memory allocation errors * Reduce memory usage * Add configure options to compile without NTP, cmdmon, refclock support * Extend makestep command to set automatic clock stepping Bug fixes --------- * Add sanity checks for time and frequency offset * Don't report synchronised status during leap second * Don't combine reference clocks with close NTP sources * Fix accepting requests from configured sources * Fix initial fallback drift setting New in version 1.31.1 ===================== Security fixes -------------- * Protect authenticated symmetric NTP associations against DoS attacks (CVE-2015-1853) * Fix access configuration with subnet size indivisible by 4 (CVE-2015-1821) * Fix initialization of reply slots for authenticated commands (CVE-2015-1822) New in version 1.31 =================== Enhancements ------------ * Support operation in other NTP eras (next era begins in 2036), NTP time is mapped to [-50, +86] years around build date by default * Restore time from driftfile with -s when RTC is missing/unsupported * Close connected client sockets when not waiting for reply * Use one client socket with random port when acquisitionport is 0 * Use NTP packets instead of UDP echo for presend * Don't adjust polling interval when sending fails * Allow binding to addresses that don't exist yet * Ignore measurements around leap second * Improve detection of unexpected time jumps * Include example of logrotate configuration, systemd services and NetworkManager dispatcher script Bug fixes --------- * Reconnect client sockets for each request to follow changes in network configuration automatically * Restart timer when polling interval is changed on reset New in version 1.30 =================== Enhancements ------------ * Add asynchronous name resolving with POSIX threads * Add PTP hardware clock (PHC) refclock driver * Add new generic clock driver to slew by adjusting frequency only (without kernel PLL or adjtime) and use it on Linux * Add rtcautotrim directive to trim RTC automatically * Add hwclockfile directive to share RTC LOCAL/UTC setting with hwclock * Add maxslewrate directive to set maximum allowed slew rate * Add maxdispersion option for refclocks * Add -q/-Q options to set clock/print offset once and exit * Allow directives to be specified on chronyd command line * Replace frequency scaling in Linux driver with retaining of tick * Try to detect unexpected forward time jumps and reset state * Exit with non-zero code when maxchange limit is reached * Improve makestep to not start and stop slew unnecessarily * Change default corrtimeratio to 3.0 to improve frequency accuracy * Announce leap second only on last day of June and December * Use separate connected client sockets for each NTP server * Remove separate NTP implementation used for initstepslew * Limit maximum minpoll set by KoD RATE to default maxpoll * Don't send NTP requests with unknown key * Print warning when source is added with unknown key * Take leap second in PPS refclock from locked source * Make reading of RTC for initial trim more reliable * Don't create cmdmon sockets when cmdport is 0 * Add configure option to set default user to drop root privileges * Add configure option to compile with debug messages * Print debug messages when -d is used more than once * Change format of messages written to terminal with -d * Write fatal messages also to stderr with -n * Use IP_RECVERR socket option in chronyc to not wait unnecessarily * Shorten default chronyc timeout for localhost * Change default hostname in chronyc from localhost to 127.0.0.1 * Print error message on invalid syntax with all chronyc commands * Include simulation test suite using clknetsim Bug fixes --------- * Fix crash when selecting with multiple preferred sources * Fix frequency calculation with large frequency offsets * Fix code writing drift and RTC files to compile correctly * Fix -4/-6 options in chronyc to not reset hostname set by -h * Fix refclock sample validation with sub-second polling interval * Set stratum correctly with non-PPS SOCK refclock and local stratum * Modify dispersion accounting in refclocks to prevent PPS getting stuck with large dispersion and not accepting new samples New in version 1.29.1 ===================== Security fixes -------------- * Modify chronyc protocol to prevent amplification attacks (CVE-2014-0021) (incompatible with previous protocol version, chronyc supports both) New in version 1.29 =================== Security fixes -------------- * Fix crash when processing crafted commands (CVE-2012-4502) (possible with IP addresses allowed by cmdallow and localhost) * Don't send uninitialized data in SUBNETS_ACCESSED and CLIENT_ACCESSES replies (CVE-2012-4503) (not used by chronyc) Other changes ------------- * Drop support for SUBNETS_ACCESSED and CLIENT_ACCESSES commands New in version 1.28 =================== * Combine sources to improve accuracy * Make config and command parser strict * Add -a option to chronyc to authenticate automatically * Add -R option to ignore initstepslew and makestep directives * Add generatecommandkey, minsamples, maxsamples and user directives * Improve compatibility with NTPv1 and NTPv2 clients * Create sockets only in selected family with -4/-6 option * Treat address bind errors as non-fatal * Extend tracking log * Accept float values as initstepslew threshold * Allow hostnames in offline, online and burst commands * Fix and improve peer polling * Fix crash in config parsing with too many servers * Fix crash with duplicated initstepslew address * Fix delta calculation with extreme frequency offsets * Set local stratum correctly * Remove unnecessary adjtimex calls * Set paths in documentation by configure * Update chrony.spec New in version 1.27 =================== * Support for stronger keys via NSS or libtomcrypt library * Support reading leap second data from tz database * Support for precise clock stepping on Linux * Support for nanoseconds in SHM refclock * Make offset corrections smoother on Linux * Make transmit timestamps random below clock precision * Add corrtimeratio and maxchange directives * Extend tracking, sources and activity reports * Wait in foreground process until daemon is fully initialized * Fix crash with slow name resolving * Fix iburst with jittery sources * Fix offset stored in rtc data right after trimrtc * Fix crash and hang with RTC or manual samples * Don't use readonly adjtime on Linux kernels before 2.6.28 * Changed chronyc protocol, incompatible with older versions New in version 1.26 =================== * Add compatibility with Linux 3.0 and later * Use proper source address in NTP replies on multihomed IPv6 hosts * Accept NTP packets with versions 4, 3 and 2 * Cope with unexpected backward time jumps * Don't reset kernel frequency on start without drift file * Retry on permanent DNS error by default * Add waitsync command New in version 1.25 =================== * Improve accuracy with NTP sources * Improve accuracy with reference clocks * Improve polling interval adjustment * Improve stability with temporary asymmetric delays * Improve source selection * Improve initial synchronisation * Add delayed server name resolving * Add temperature compensation * Add nanosecond slewing to Linux driver * Add fallback drifts * Add iburst, minstratum, maxdelaydevratio, polltarget, prefer, noselect options * Add rtcsync directive to enable Linux 11-minute mode * Add reselectdist, stratumweight, logbanner, maxclockerror, include directives * Add -n option to not detach daemon from terminal * Fix pidfile directive * Fix name resolving with disabled IPv6 support * Fix reloading sample histories with reference clocks * Fix crash with auto_offline option * Fix online command on auto_offline sources * Fix file descriptor leaks * Increase burst polling interval and stop on KoD RATE * Set maxupdateskew to 1000 ppm by default * Require password for clients command * Update drift file at most once per hour * Use system headers for Linux RTC support * Reduce default chronyc timeout and make it configurable * Avoid large values in chronyc sources and sourcestats output * Add reselect command to force reselecting best source * Add -m option to allow multiple commands on command line New in version 1.24 =================== Security fixes -------------- * Don't reply to invalid cmdmon packets (CVE-2010-0292) * Limit client log memory size (CVE-2010-0293) * Limit rate of syslog messages (CVE-2010-0294) Bug fixes/Enhancements ---------------------- * Support for reference clocks (SHM, SOCK, PPS drivers) * IPv6 support * Linux capabilities support (to drop root privileges) * Memory locking support on Linux * Real-time scheduler support on Linux * Leap second support on Linux * Support for editline library * Support for new Linux readonly adjtime * NTP client support for KoD RATE * Read kernel timestamps for received NTP packets * Reply to NTP requests with correct address on multihomed hosts * Retry name resolving after temporary failure * Fix makestep command, make it available on all systems * Add makestep directive for automatic clock stepping * Don't require _bigadj kernel symbol on NetBSD * Avoid blocking read in Linux RTC driver * Support for Linux on S/390 and PowerPC * Fix various bugs on 64-bit systems * Fix valgrind errors and compiler warnings * Improve configure to support common options and variables * Improve status checking and printing in chronyc * Return non-zero exit code on errors in chronyc * Reduce request timeout in chronyc * Print estimated offset in sourcestats * Changed chronyc protocol, incompatible with older versions New in version 1.23 =================== * Support for MIPS, x86_64, sparc, alpha, arm, FreeBSD * Fix serious sign-extension error in handling IP addresses * RTC support can be excluded at compile time * Make sources gcc-4 compatible * Fix various compiler warnings * Handle fluctuations in peer distance better. * Fixed handling of stratum zero. * Fix various problems for 64-bit systems * Flush chronyc output streams after each command, to allow it to be driven through pipes * Manpage improvements Version 1.22 ============ This release number was claimed by a release that Mandriva made to patch important bugs in 1.21. The official numbering has jumped to 1.23 as a consequence. New in version 1.21 =================== * Don't include Linux kernel header files any longer : allows chrony to compile on recent distros. * Stop trying to use RTC if continuous streams of error messages would occur (Linux with HPET). New in version 1.20 =================== * Many small tidy-ups and security improvements * Improve documentation (RTC support in post 2.0 kernels) * Remove trailing \n from syslog messages * Syslog messages now include IP and port number when packet cannot be sent. * Added the "acquisitionport" directive. (Kalle Olavi Niemitalo) * Use uname(2) instead of /proc/version to get kernel version. * Merge support for Linux on Alpha * Merge support for 64bit architectures * Don't link -lm if it's not needed * Fix Solaris build (broken by 64bit change) * Add detection of Linux 2.5 * Allow arbitrary value of HZ in Linux kernel * Fix for chrony.spec on SuSE (Paul Elliot) * Fix handling of initstepslew if no servers are listed (John Hasler) * Fix install rule in Makefile if chronyd is in use (Juliusz Chroboczek) * Replace sprintf by snprintf to remove risk of buffer overrun (John Hasler) * Add --help to configure script New in version 1.19 =================== * Auto-detect kernel's timer interrupt rate (so-called 'HZ') when chronyd starts instead of relying on compiled-in value. * Fix 2 bugs in function that creates the directory for the log and dump files. * Amended webpage URL and contact details. * Generate more informative syslog messages before exiting on failed assertions. * Fix bugs in clamping code for the tick value used when slewing a large offset. * Don't chown files to root during install (should be pointless, and makes RPM building awkward as ordinary user.) * Include chrony.spec file for building RPMs New in version 1.18 =================== * Amend homepage and mailing list information to chrony.sunsite.dk * Delete pidfile on exit from chronyd. * Improvements to readline interface to chronyc * Only generate syslog message when synchronisation is initially lost (instead of on every failed synchronisation attempt) * Use double fork approach when initialising daemon. * More things in contrib directory. * New options to help package builders: --infodir/--mandir for configure, and DESTDIR=xxx for make. (See section 2.2 of chrony.txt for details). * Changed the wording of the messages generated by mailonchange and logchange directives. New in version 1.17 =================== * Port to NetBSD * Configuration supports Linux on PPC * Fix compilation warnings * Several documentation improvements * Bundled manpages (taken from the 'missing manpages project') * Cope with lack of bzero function for Solaris 2.3 systems * Store chronyd's pid in a file (default /var/run/chronyd.pid) and check if chronyd may already be running when starting up. New pidfile directive in configuration file. * Any size subnet is now allowed in allow and deny commands. (Example: 6.7.8/20 or 6.7.8.x/20 (any x) mean a 20 bit subnet). * The environment variables CC and CFLAGS passed to configure can now be used to select the compiler and optimisation/debug options to use * Write syslog messages when chronyd loses synchronisation. * Print GPL text when chronyc is run. * Add NTP broadcast server capability (new broadcast directive). * Add 'auto_offline' option to server/peer (conf file) or add server/peer (via chronyc). * Add 'activity' command to chronyc, to report how many servers/peers are currently online/offline. * Fix long-standing bug with how the system time quantum was calculated. * Include support for systems with HZ!=100 (HZ is the timer interrupt frequency). * Include example chrony.conf and chrony.keys files (examples subdirectory). * Include support for readline in chronyc. New in version 1.16.1 ===================== * Fix compilation problem on Linux 2.4.13 (spinlock.h / spinlock_t) New in version 1.16 =================== * More informative captions for 'sources' and 'sourcestats' commands in chronyc (use 'sources -v' and 'sourcestats -v' to get them). * Correct behaviour for Solaris versions>=2.6 (dosynctodr not required on these versions.) * Remove some compiler warnings (Solaris) * If last line of keys file doesn't have end-of-line, don't truncate final character of that key. * Change timestamp format used in logfiles to make it fully numeric (to aid importing data into spreadsheets etc) * Minor documentation updates and improvements. New in version 1.15 =================== * Add contributed change to 'configure' to support Solaris 2.8 on x86 * Workaround for assertion failure that arises if two received packets occur close together. (Still need to find out why this happens at all.) * Hopefully fix problem where fast slewing was incompatible with machines that have a large background drift rate (=> tick value went out of range for adjtimex() on Linux.) * Fix rtc_linux.c compile problems with 2.4.x kernel include files. * Include support for RTC device not being at /dev/rtc (new rtcdevice directive in configuration file). * Include support for restricting network interfaces for commands (new bindcmdaddress directive in configuration file) * Fix potential linking fault in pktlength.c (use of CROAK macro replaced by normal assert). * Add some material on bug reporting + contributing to the chrony.texi file * Made the chrony.texi file "Vim6-friendly" (removed xrefs on @node lines, added folding markers to chapters + sections.) * Switched over to GPL for the licence New in version 1.14 =================== * Fix compilation for certain other Linux distributions (including Mandrake 7.1) New in version 1.13 =================== * Fixed compilation problems on Redhat/SuSE installations with recent 2.2.x kernels. * Minor tidy-ups and documentation enhancements. * Add support for Linux 2.4 kernels New in version 1.12 =================== * Trial fix for long-standing bug in Linux RTC estimator when system time is slewed. * Fix bug in chronyc if -h is specified without a hostname * Fixes to logging various error conditions when operating in daemon mode. * More stuff under contrib/ * Changes to README file (e.g. about the new chrony-users mailing list) New in version 1.11a ==================== * Minor changes to contact details * Minor changes to installation details (chrony subdirectory under doc/) New in version 1.11 =================== * Improve robustness of installation procedure * Tidy up documenation and contact details * Distribute manual as .txt rather than as .ps * Add -n option to chronyc to work with numeric IP addresses rather than names. * Add material in contrib subdirectory * Improve robustness of handling drift file and RTC coefficients file * Improve robustness of regression algorithm New in version 1.1 ================== Bug fixes --------- * Made linear regression more resistant to rounding errors (old one occasionally generated negative variances which made everything go haywire). Trap infinite or 'not-a-number' values being used to alter system clock to increase robustness further. Other changes/Enhancements -------------------------- * Support for Linux 2.1 and 2.2 kernels * New command 'makestep' in chronyc to immediately jump the system time to match the NTP estimated time (Linux only) - a response to systems booting an hour wrong after summertime/wintertime changes, due to RTCs running on local time. Needs extending to Sun driver files too. * New directives 'logchange' and 'mailonchange' to log to syslog or email to a specific address respectively if chronyd detects a clock offset exceeding a defined threshold. * Added capability to log all client/peer NTP accesses and command accesses (can be turned off with conf file directive 'noclientlog'). Added 'clients' command to chronyc to display this data. * Improved manual mode to use robust regression rather than 2 point fit. * Added 'manual list' and 'manual delete' commands to chronyc to allow display of entered timestamps and discretionary deletion of outliers. * If host goes unsynchronised the dummy IP address 0.0.0.0 is detected to avoid attempting a reverse name lookup (to stop dial on demand IP links from being started) * Changed chronyc/chronyd protocol so messages are now all variable length. Saves on network bandwidth particularly for large replies from chronyd to chronyc (to support the clients command). * Added bindaddress directive to configuration file, to give additional control over limiting which hosts can access the local server. * Groundwork done for a port to Windows NT to compile with Cygwin toolkit. chronyc works (to monitor another host). sys_winnt.c needs finishing to use NT clock control API. Program structure needs adapting to use Windows NT service functions, so it can be started at boot time. Hopefully a Windows NT / Cygwin guru with some spare time can take this port over :-) New in version 1.02 =================== Bug fixes --------- * Fix error messages in chronyc if daemon is not reachable. * Fix config file problem for 'allow all' and 'deny all' without a trailing machine address. * Remove fatal failed assertion if command socket cannot be read from in daemon. * Rewrote timezone handling for Linux real time clock, following various reported problems related to daylight saving. Other changes/Enhancements -------------------------- * Configure script recognizes BSD/386 and uses SunOS 4.1 driver for it. * Log files now print date as day-month-year rather than as a day number. Milliseconds removed from timestamps of logged data. Banners included in file to give meanings of columns. * Only do 1 initial step (followed by a trimming slew) when initialising from RTC on Linux (previously did 2 steps). New in version 1.01 =================== Bug fixes --------- * Handle timezone of RTC correctly with respect to daylight saving time * Syntax check the chronyc 'local' command properly * Fixed assertion failed fault in median finder (used by RTC regression fitting) Other changes/Enhancements -------------------------- * Log selection of new NTP reference source to syslog. * Don't zero-pad IP address fields * Add new command to chronyc to allow logfiles to be cycled. * Extend allow/deny directive syntax in configuration file to so directive can apply to all hosts on the Internet. * Tidy up printout of timestamps to make it clear they are in UTC * Make 'configure' check the processor type as well as the operating system.
README
Zum Öffnen der im WIKI abgelegten README-Page auf die grauen Balken klicken!
$ less /usr/share/doc/chrony/README
This is the README for chrony. What is chrony? =============== chrony is a versatile implementation of the Network Time Protocol (NTP). It can synchronise the system clock with NTP servers, reference clocks (e.g. GPS receiver), and manual input using wristwatch and keyboard. It can also operate as an NTPv4 (RFC 5905) server and peer to provide a time service to other computers in the network. It is designed to perform well in a wide range of conditions, including intermittent network connections, heavily congested networks, changing temperatures (ordinary computer clocks are sensitive to temperature), and systems that do not run continuosly, or run on a virtual machine. Typical accuracy between two machines synchronised over the Internet is within a few milliseconds; on a LAN, accuracy is typically in tens of microseconds. With hardware timestamping, or a hardware reference clock, sub-microsecond accuracy may be possible. Two programs are included in chrony, chronyd is a daemon that can be started at boot time and chronyc is a command-line interface program which can be used to monitor chronyd's performance and to change various operating parameters whilst it is running. What will chrony run on? ======================== The software is known to work on Linux, FreeBSD, NetBSD, macOS and illumos. Closely related systems may work too. Any other system will likely require a porting exercise. How do I set it up? =================== The file INSTALL gives instructions. On supported systems the compilation process should be automatic. You will need a C compiler, e.g. gcc or clang. What documentation is there? ============================ The distribution includes manual pages and a document containing Frequently Asked Questions (FAQ). The documentation is also available on the chrony web pages, accessible through the URL https://chrony-project.org/ License ======= chrony is distributed under the GNU General Public License version 2. Authors ======= Richard P. Curnow <rc@rc0.org.uk> Miroslav Lichvar <mlichvar@redhat.com> Acknowledgements ================ In writing the chronyd program, extensive use has been made of the NTPv3 (RFC 1305) and NTPv4 (RFC 5905) specification. The source code of the xntpd/ntpd implementation written by Dennis Fergusson, Lars Mathiesen, David Mills, and others has been used to check the details of the protocol. The following people have provided patches and other major contributions to chrony: Lonnie Abelbeck <lonnie@abelbeck.com> Benny Lyne Amorsen <benny@amorsen.dk> Andrew Bishop <amb@gedanken.demon.co.uk> Vincent Blut <vincent.debian@free.fr> Stephan I. Boettcher <stephan@nevis1.columbia.edu> David Bohman <debohman@gmail.com> Goswin Brederlow <brederlo@informatik.uni-tuebingen.de> Leigh Brown <leigh@solinno.co.uk> Erik Bryer <ebryer@spots.ab.ca> Jonathan Cameron <jic23@cam.ac.uk> Bryan Christianson <bryan@whatroute.net> Juliusz Chroboczek <jch@pps.jussieu.fr> Dan Drown <dan-ntp@drown.org> Kamil Dudka <kdudka@redhat.com> Christian Ehrhardt <christian.ehrhardt@canonical.com> Paul Elliott <pelliott@io.com> Robert Fairley <rfairley@redhat.com> Stefan R. Filipek <srfilipek@gmail.com> Mike Fleetwood <mike@rockover.demon.co.uk> Alexander Gretencord <arutha@gmx.de> Andrew Griffiths <agriffit@redhat.com> Walter Haidinger <walter.haidinger@gmx.at> Juergen Hannken-Illjes <hannken@eis.cs.tu-bs.de> John Hasler <john@dhh.gt.org> Tjalling Hattink <t.hattink@fugro.nl> Liam Hatton <me@liamhatton.com> Holger Hoffstätte <holger@applied-asynchrony.com> Jachym Holecek <jakym@volny.cz> Håkan Johansson <f96hajo@chalmers.se> Jim Knoble <jmknoble@pobox.com> Antti Jrvinen <costello@iki.fi> Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Eric Lammerts <eric@lammerts.org> Stefan Lucke <stefan@lucke.in-berlin.de> Victor Lum <viclum@vanu.com> Kevin Lyda <kevin@ie.suberic.net> Paul Menzel <paulepanter@users.sourceforge.net> Vladimir Michl <vladimir.michl@seznam.cz> Victor Moroz <vim@prv.adlum.ru> Kalle Olavi Niemitalo <tosi@stekt.oulu.fi> Frank Otto <sandwichmacher@web.de> Denny Page <dennypage@me.com> Rupesh Patel <rupatel@redhat.com> Chris Perl <cperl@janestreet.com> Gautier PHILIPPON <gautier.philippon@ensimag.grenoble-inp.fr> Andreas Piesk <apiesk@virbus.de> Mike Ryan <msr@hsilop.net> Baruch Siach <baruch@tkos.co.il> Josef 'Jeff' Sipek <jeffpc@josefsipek.net> Foster Snowhill <forst@forstwoof.ru> Andreas Steinmetz <ast@domdv.de> NAKAMURA Takumi <takumi@ps.sakura.ne.jp> Timo Teras <timo.teras@iki.fi> Bill Unruh <unruh@physics.ubc.ca> Luke Valenta <lvalenta@cloudflare.com> Stephen Wadeley <swadeley@redhat.com> Bernhard Weiss <lisnablagh@web.de> Wolfgang Weisselberg <weissel@netcologne.de> Bernhard M. Wiedemann <bwiedemann@suse.de> Joachim Wiedorn <ad_debian@joonet.de> Ralf Wildenhues <Ralf.Wildenhues@gmx.de> Ulrich Windl <ulrich.windl@rz.uni-regensburg.de> Michael Witten <mfwitten@gmail.com> Doug Woodward <dougw@whistler.com> Thomas Zajic <zlatko@zlatko.fdns.net> Many other people have contributed bug reports and suggestions. We are sorry we cannot identify all of you individually.
Konfiguration
Wie schon zuvor angemerkt, finden sich im Verzeichnis /usr/share/doc/chrony/examples/
entsprechen hilfreiche Konfigurationsbeispiele.
# tree /usr/share/doc/chrony/examples/
/usr/share/doc/chrony/examples/ ├── chrony.conf.example1 ├── chrony.conf.example2 ├── chrony.conf.example3 ├── chronyd-restricted.service ├── chronyd.service ├── chrony.keys.example ├── chrony.logrotate ├── chrony.nm-dispatcher.dhcp ├── chrony.nm-dispatcher.onoffline └── chrony-wait.service
Wir wollen uns nun zwei Standardkonfigurationsbeispiele nun nachfolgend etwas genauer ansehen.
Bevor wir nun aber unseren Chrony-Daemon - egal ob wird nun chrony als Server oder als Client betreiben wollen - werden wir zunächst die im Paket mitgelieferte Original-Konfigurationsdatei /etc/chrony.conf
für spätere Referenzen sichern.
# cp -a /etc/chrony.conf /etc/chrony.conf.orig
Zum Öffnen der im WIKI abgelegten originalen KOnfigurationsdatei /etc/chrony.conf.orig
auf die grauen Balken klicken!
$ less /etc/chrony.conf.orig
- /etc/chrony.conf.orig
####################################################################### # # This is an example chrony configuration file. You should copy it to # /etc/chrony.conf after uncommenting and editing the options that you # want to enable. The more obscure options are not included. Refer # to the documentation for these. # ####################################################################### ### COMMENTS # Any of the following lines are comments (you have a choice of # comment start character): # a comment % a comment ! a comment ; a comment # # Below, the '!' form is used for lines that you might want to # uncomment and edit to make your own chrony.conf file. # ####################################################################### ####################################################################### ### SPECIFY YOUR NTP SERVERS # Most computers using chrony will send measurement requests to one or # more 'NTP servers'. You will probably find that your Internet Service # Provider or company have one or more NTP servers that you can specify. # Failing that, there are a lot of public NTP servers. There is a list # you can access at http://support.ntp.org/bin/view/Servers/WebHome or # you can use servers from the pool.ntp.org project. ! server ntp1.example.net iburst ! server ntp2.example.net iburst ! server ntp3.example.net iburst pool 2.arch.pool.ntp.org iburst ####################################################################### ### AVOIDING POTENTIALLY BOGUS CHANGES TO YOUR CLOCK # # To avoid changes being made to your computer's gain/loss compensation # when the measurement history is too erratic, you might want to enable # one of the following lines. The first seems good with servers on the # Internet, the second seems OK for a LAN environment. ! maxupdateskew 100 ! maxupdateskew 5 # If you want to increase the minimum number of selectable sources # required to update the system clock in order to make the # synchronisation more reliable, uncomment (and edit) the following # line. ! minsources 2 # If your computer has a good stable clock (e.g. it is not a virtual # machine), you might also want to reduce the maximum assumed drift # (frequency error) of the clock (the value is specified in ppm). ! maxdrift 100 # By default, chronyd allows synchronisation to an unauthenticated NTP # source (i.e. specified without the nts and key options) if it agrees with # a majority of authenticated NTP sources, or if no authenticated source is # specified. If you don't want chronyd to ever synchronise to an # unauthenticated NTP source, uncomment the first from the following lines. # If you don't want to synchronise to an unauthenticated NTP source only # when an authenticated source is specified, uncomment the second line. # If you want chronyd to ignore authentication in the source selection, # uncomment the third line. ! authselectmode require ! authselectmode prefer ! authselectmode ignore ####################################################################### ### FILENAMES ETC # Chrony likes to keep information about your computer's clock in files. # The 'driftfile' stores the computer's clock gain/loss rate in parts # per million. When chronyd starts, the system clock can be tuned # immediately so that it doesn't gain or lose any more time. You # generally want this, so it is uncommented. driftfile /var/lib/chrony/drift # If you want to enable NTP authentication with symmetric keys, you will need # to uncomment the following line and edit the file to set up the keys. ! keyfile /etc/chrony.keys # If you specify an NTP server with the nts option to enable authentication # with the Network Time Security (NTS) mechanism, or enable server NTS with # the ntsservercert and ntsserverkey directives below, the following line will # allow the client/server to save the NTS keys and cookies in order to reduce # the number of key establishments (NTS-KE sessions). ntsdumpdir /var/lib/chrony # If chronyd is configured to act as an NTP server and you want to enable NTS # for its clients, you will need a TLS certificate and private key. Uncomment # and edit the following lines to specify the locations of the certificate and # key. ! ntsservercert /etc/.../nts-server.crt ! ntsserverkey /etc/.../nts-server.key # chronyd can save the measurement history for the servers to files when # it exits. This is useful in 2 situations: # # 1. If you stop chronyd and restart it with the '-r' option (e.g. after # an upgrade), the old measurements will still be relevant when chronyd # is restarted. This will reduce the time needed to get accurate # gain/loss measurements. # # 2. On Linux, if you use the RTC support and start chronyd with # '-r -s' on bootup, measurements from the last boot will still be # useful (the real time clock is used to 'flywheel' chronyd between # boots). # # Uncomment the following line to use this. ! dumpdir /var/lib/chrony # chronyd writes its process ID to a file. If you try to start a second # copy of chronyd, it will detect that the process named in the file is # still running and bail out. If you want to change the path to the PID # file, uncomment this line and edit it. The default path is shown. ! pidfile /var/run/chrony/chronyd.pid # If the system timezone database is kept up to date and includes the # right/UTC timezone, chronyd can use it to determine the current # TAI-UTC offset and when will the next leap second occur. leapsectz right/UTC ####################################################################### ### INITIAL CLOCK CORRECTION # This option is useful to quickly correct the clock on start if it's # off by a large amount. The value '1.0' means that if the error is less # than 1 second, it will be gradually removed by speeding up or slowing # down your computer's clock until it is correct. If the error is above # 1 second, an immediate time jump will be applied to correct it. The # value '3' means the step is allowed only in the first three updates of # the clock. Some software can get upset if the system clock jumps # (especially backwards), so be careful! makestep 1.0 3 ####################################################################### ### LEAP SECONDS # A leap second is an occasional one-second correction of the UTC # time scale. By default, chronyd tells the kernel to insert/delete # the leap second, which makes a backward/forward step to correct the # clock for it. As with the makestep directive, this jump can upset # some applications. If you prefer chronyd to make a gradual # correction, causing the clock to be off for a longer time, uncomment # the following line. ! leapsecmode slew ####################################################################### ### LOGGING # If you want to log information about the time measurements chronyd has # gathered, you might want to enable the following lines. You probably # only need this if you really enjoy looking at the logs, you want to # produce some graphs of your system's timekeeping performance, or you # need help in debugging a problem. ! logdir /var/log/chrony ! log measurements statistics tracking # If you have real time clock support enabled (see below), you might want # this line instead: ! log measurements statistics tracking rtc ####################################################################### ### ACTING AS AN NTP SERVER # You might want the computer to be an NTP server for other computers. # # By default, chronyd does not allow any clients to access it. You need # to explicitly enable access using 'allow' and 'deny' directives. # # e.g. to enable client access from the 192.168.*.* class B subnet, ! allow 192.168/16 # .. but disallow the 192.168.100.* subnet of that, ! deny 192.168.100/24 # You can have as many allow and deny directives as you need. The order # is unimportant. # If you want to present your computer's time for others to synchronise # with, even if you don't seem to be synchronised to any NTP servers # yourself, enable the following line. The value 10 may be varied # between 1 and 15. You should avoid small values because you will look # like a real NTP server. The value 10 means that you appear to be 10 # NTP 'hops' away from an authoritative source (atomic clock, GPS # receiver, radio clock etc). ! local stratum 10 # Normally, chronyd will keep track of how many times each client # machine accesses it. The information can be accessed by the 'clients' # command of chronyc. You can disable this facility by uncommenting the # following line. This will save a bit of memory if you have many # clients and it will also disable support for the interleaved mode. ! noclientlog # The clientlog size is limited to 512KB by default. If you have many # clients, you might want to increase the limit. ! clientloglimit 4194304 # By default, chronyd tries to respond to all valid NTP requests from # allowed addresses. If you want to limit the response rate for NTP # clients that are sending requests too frequently, uncomment and edit # the following line. ! ratelimit interval 3 burst 8 ####################################################################### ### REPORTING BIG CLOCK CHANGES # Perhaps you want to know if chronyd suddenly detects any large error # in your computer's clock. This might indicate a fault or a problem # with the server(s) you are using, for example. # # The next option causes a message to be written to syslog when chronyd # has to correct an error above 0.5 seconds (you can use any amount you # like). ! logchange 0.5 # The next option will send email to the named person when chronyd has # to correct an error above 0.5 seconds. (If you need to send mail to # several people, you need to set up a mailing list or sendmail alias # for them and use the address of that.) ! mailonchange wibble@example.net 0.5 ####################################################################### ### COMMAND ACCESS # The program chronyc is used to show the current operation of chronyd # and to change parts of its configuration whilst it is running. # By default chronyd binds to the loopback interface. Uncomment the # following lines to allow receiving command packets from remote hosts. ! bindcmdaddress 0.0.0.0 ! bindcmdaddress :: # Normally, chronyd will only allow connections from chronyc on the same # machine as itself. This is for security. If you have a subnet # 192.168.*.* and you want to be able to use chronyc from any machine on # it, you could uncomment the following line. (Edit this to your own # situation.) ! cmdallow 192.168/16 # You can add as many 'cmdallow' and 'cmddeny' lines as you like. The # syntax and meaning is the same as for 'allow' and 'deny', except that # 'cmdallow' and 'cmddeny' control access to the chronyd's command port. # Rate limiting can be enabled also for command packets. (Note, # commands from localhost are never limited.) ! cmdratelimit interval -4 burst 16 ####################################################################### ### HARDWARE TIMESTAMPING # On Linux, if the network interface controller and its driver support # hardware timestamping, it can significantly improve the accuracy of # synchronisation. It can be enabled on specified interfaces only, or it # can be enabled on all interfaces that support it. ! hwtimestamp eth0 ! hwtimestamp * ####################################################################### ### REAL TIME CLOCK # chronyd can characterise the system's real-time clock. This is the # clock that keeps running when the power is turned off, so that the # machine knows the approximate time when it boots again. The error at # a particular epoch and gain/loss rate can be written to a file and # used later by chronyd when it is started with the '-s' option. # # You need to have 'enhanced RTC support' compiled into your Linux # kernel. (Note, these options apply only to Linux.) ! rtcfile /var/lib/chrony/rtc # Your RTC can be set to keep Universal Coordinated Time (UTC) or local # time. (Local time means UTC +/- the effect of your timezone.) If you # use UTC, chronyd will function correctly even if the computer is off # at the epoch when you enter or leave summer time (aka daylight saving # time). However, if you dual boot your system with Microsoft Windows, # that will work better if your RTC maintains local time. You take your # pick! ! rtconutc # By default chronyd assumes that the enhanced RTC device is accessed as # /dev/rtc. If it's accessed somewhere else on your system (e.g. you're # using devfs), uncomment and edit the following line. ! rtcdevice /dev/misc/rtc # Alternatively, if not using the -s option, this directive can be used # to enable a mode in which the RTC is periodically set to the system # time, with no tracking of its drift. rtcsync ####################################################################### ### REAL TIME SCHEDULER # This directive tells chronyd to use the real-time FIFO scheduler with the # specified priority (which must be between 0 and 100). This should result # in reduced latency. You don't need it unless you really have a requirement # for extreme clock stability. Works only on Linux. Note that the "-P" # command-line switch will override this. ! sched_priority 1 ####################################################################### ### LOCKING CHRONYD INTO RAM # This directive tells chronyd to use the mlockall() syscall to lock itself # into RAM so that it will never be paged out. This should result in reduced # latency. You don't need it unless you really have a requirement # for extreme clock stability. Works only on Linux. Note that the "-m" # command-line switch will also enable this feature. ! lock_all
So können wir bei etwaigen Bedarf Vergleiche zur originalen Konfigurationsdatei mit unserer individuellen Konfigurationsdatei anstreben, wie in diesem Beispiel hier:
# vimdiff /etc/chrony.conf /etc/chrony.conf.orig
Client
Bei der Konfiguration unseres chrony-Clients reicht es völlig aus, wenn wir uns auf die Definition unseres Timeserver(pools) beschränken. Alle anderen Optionen in der mitgelieferten Konfigurationsdatei sind bereits auf valide Grundwerte gesetzt, so dass wir uns hier nicht gross weiter mit Details beschäftigen müssen.
Im Abschnitt SPECIFY YOUR NTP SERVERS hinterlegen wir nun also den NTP-Server unserer Wahl.
# vim /etc/chrony.conf
- /etc/chrony.conf
... ####################################################################### ####################################################################### ### SPECIFY YOUR NTP SERVERS # Most computers using chrony will send measurement requests to one or # more 'NTP servers'. You will probably find that your Internet Service # Provider or company have one or more NTP servers that you can specify. # Failing that, there are a lot of public NTP servers. There is a list # you can access at http://support.ntp.org/bin/view/Servers/WebHome or # you can use servers from the pool.ntp.org project. ! server ntp1.example.net iburst ! server ntp2.example.net iburst ! server ntp3.example.net iburst server time.dmz.nausch.org iburst ...
Vereinfacht zusammengefasst ist dies im Grunde die Beispielskonfigurationsdatei die /usr/share/doc/chrony/examples/chrony.conf.example1
die uns das Paket chrony hat mitgeliefert - wir haben hier „nur“ unseren eigenen NTP-Server eingetragen.
# less /usr/share/doc/chrony/examples/chrony.conf.example1
- /usr/share/doc/chrony/examples/chrony.conf.example1
# Use public NTP servers from the pool.ntp.org project. pool 2.arch.pool.ntp.org iburst # Record the rate at which the system clock gains/losses time. driftfile /var/lib/chrony/drift # Allow the system clock to be stepped in the first three updates # if its offset is larger than 1 second. makestep 1.0 3 # Enable kernel synchronization of the real-time clock (RTC). rtcsync
Server
Chrony Daemon
Im zweiten Konfigurationsbeispiel widmen wir uns unserem Arch Linux Server, der als interner Zeitserver agieren und der von mehreren vertrauenswürdigen NTP-Server im Internet die Uhrzeit holen und auch synchron halten soll.
Die Konfiguration unseres Chrony-Daemon, oder genauer gesagt unseres NTP-Servers mit Hilfe von chrony, erfolgt wie auch bei der zuvor gezeigten Clientkonfiguration über die Datei /etc/chrony.conf
. Mit dem Editor unserer Wahl bearbeiten wir nun diese Datei. In nachfolgendem Konfigurationsbeispiel wurden alle relavanten Änderungen mit Admin-Name und Datum versehen, also z.B. # Django : 2024-02-18
# vim /etc/chrony.conf
- /etc/chrony.conf
####################################################################### # # This is an example chrony configuration file. You should copy it to # /etc/chrony.conf after uncommenting and editing the options that you # want to enable. The more obscure options are not included. Refer # to the documentation for these. # ####################################################################### ### COMMENTS # Any of the following lines are comments (you have a choice of # comment start character): # a comment % a comment ! a comment ; a comment # # Below, the '!' form is used for lines that you might want to # uncomment and edit to make your own chrony.conf file. # ####################################################################### ####################################################################### ### SPECIFY YOUR NTP SERVERS # Most computers using chrony will send measurement requests to one or # more 'NTP servers'. You will probably find that your Internet Service # Provider or company have one or more NTP servers that you can specify. # Failing that, there are a lot of public NTP servers. There is a list # you can access at http://support.ntp.org/bin/view/Servers/WebHome or # you can use servers from the pool.ntp.org project. ! server ntp1.example.net iburst ! server ntp2.example.net iburst ! server ntp3.example.net iburst # Django : 2024-02-18 pool pool.ntp.org iburst ####################################################################### ### AVOIDING POTENTIALLY BOGUS CHANGES TO YOUR CLOCK # # To avoid changes being made to your computer's gain/loss compensation # when the measurement history is too erratic, you might want to enable # one of the following lines. The first seems good with servers on the # Internet, the second seems OK for a LAN environment. ! maxupdateskew 100 ! maxupdateskew 5 # If you want to increase the minimum number of selectable sources # required to update the system clock in order to make the # synchronisation more reliable, uncomment (and edit) the following # line. ! minsources 2 # If your computer has a good stable clock (e.g. it is not a virtual # machine), you might also want to reduce the maximum assumed drift # (frequency error) of the clock (the value is specified in ppm). ! maxdrift 100 # By default, chronyd allows synchronisation to an unauthenticated NTP # source (i.e. specified without the nts and key options) if it agrees with # a majority of authenticated NTP sources, or if no authenticated source is # specified. If you don't want chronyd to ever synchronise to an # unauthenticated NTP source, uncomment the first from the following lines. # If you don't want to synchronise to an unauthenticated NTP source only # when an authenticated source is specified, uncomment the second line. # If you want chronyd to ignore authentication in the source selection, # uncomment the third line. ! authselectmode require ! authselectmode prefer ! authselectmode ignore ####################################################################### ### FILENAMES ETC # Chrony likes to keep information about your computer's clock in files. # The 'driftfile' stores the computer's clock gain/loss rate in parts # per million. When chronyd starts, the system clock can be tuned # immediately so that it doesn't gain or lose any more time. You # generally want this, so it is uncommented. driftfile /var/lib/chrony/drift # If you want to enable NTP authentication with symmetric keys, you will need # to uncomment the following line and edit the file to set up the keys. ! keyfile /etc/chrony.keys # If you specify an NTP server with the nts option to enable authentication # with the Network Time Security (NTS) mechanism, or enable server NTS with # the ntsservercert and ntsserverkey directives below, the following line will # allow the client/server to save the NTS keys and cookies in order to reduce # the number of key establishments (NTS-KE sessions). ntsdumpdir /var/lib/chrony # If chronyd is configured to act as an NTP server and you want to enable NTS # for its clients, you will need a TLS certificate and private key. Uncomment # and edit the following lines to specify the locations of the certificate and # key. ! ntsservercert /etc/.../nts-server.crt ! ntsserverkey /etc/.../nts-server.key # chronyd can save the measurement history for the servers to files when # it exits. This is useful in 2 situations: # # 1. If you stop chronyd and restart it with the '-r' option (e.g. after # an upgrade), the old measurements will still be relevant when chronyd # is restarted. This will reduce the time needed to get accurate # gain/loss measurements. # # 2. On Linux, if you use the RTC support and start chronyd with # '-r -s' on bootup, measurements from the last boot will still be # useful (the real time clock is used to 'flywheel' chronyd between # boots). # # Uncomment the following line to use this. ! dumpdir /var/lib/chrony # Django : 2024-02-18 dumpdir /var/lib/chrony # chronyd writes its process ID to a file. If you try to start a second # copy of chronyd, it will detect that the process named in the file is # still running and bail out. If you want to change the path to the PID # file, uncomment this line and edit it. The default path is shown. ! pidfile /var/run/chrony/chronyd.pid # If the system timezone database is kept up to date and includes the # right/UTC timezone, chronyd can use it to determine the current # TAI-UTC offset and when will the next leap second occur. leapsectz right/UTC ####################################################################### ### INITIAL CLOCK CORRECTION # This option is useful to quickly correct the clock on start if it's # off by a large amount. The value '1.0' means that if the error is less # than 1 second, it will be gradually removed by speeding up or slowing # down your computer's clock until it is correct. If the error is above # 1 second, an immediate time jump will be applied to correct it. The # value '3' means the step is allowed only in the first three updates of # the clock. Some software can get upset if the system clock jumps # (especially backwards), so be careful! makestep 1.0 3 ####################################################################### ### LEAP SECONDS # A leap second is an occasional one-second correction of the UTC # time scale. By default, chronyd tells the kernel to insert/delete # the leap second, which makes a backward/forward step to correct the # clock for it. As with the makestep directive, this jump can upset # some applications. If you prefer chronyd to make a gradual # correction, causing the clock to be off for a longer time, uncomment # the following line. ! leapsecmode slew ####################################################################### ### LOGGING # If you want to log information about the time measurements chronyd has # gathered, you might want to enable the following lines. You probably # only need this if you really enjoy looking at the logs, you want to # produce some graphs of your system's timekeeping performance, or you # need help in debugging a problem. ! logdir /var/log/chrony ! log measurements statistics tracking # If you have real time clock support enabled (see below), you might want # this line instead: ! log measurements statistics tracking rtc ####################################################################### ### ACTING AS AN NTP SERVER # You might want the computer to be an NTP server for other computers. # # By default, chronyd does not allow any clients to access it. You need # to explicitly enable access using 'allow' and 'deny' directives. # # e.g. to enable client access from the 192.168.*.* class B subnet, ! allow 192.168/16 # Django : 2024-02-18 allow fd00::/10 allow 10.0.0.0/24 allow 2003:a:e0d:7603::/64 allow 192.168.0.0/24 allow 2003:a:e0d:7607::/64 # .. but disallow the 192.168.100.* subnet of that, ! deny 192.168.100/24 # You can have as many allow and deny directives as you need. The order # is unimportant. # If you want to present your computer's time for others to synchronise # with, even if you don't seem to be synchronised to any NTP servers # yourself, enable the following line. The value 10 may be varied # between 1 and 15. You should avoid small values because you will look # like a real NTP server. The value 10 means that you appear to be 10 # NTP 'hops' away from an authoritative source (atomic clock, GPS # receiver, radio clock etc). ! local stratum 10 # Django : 2024-02-18 local stratum 3 # Normally, chronyd will keep track of how many times each client # machine accesses it. The information can be accessed by the 'clients' # command of chronyc. You can disable this facility by uncommenting the # following line. This will save a bit of memory if you have many # clients and it will also disable support for the interleaved mode. ! noclientlog # The clientlog size is limited to 512KB by default. If you have many # clients, you might want to increase the limit. ! clientloglimit 4194304 # By default, chronyd tries to respond to all valid NTP requests from # allowed addresses. If you want to limit the response rate for NTP # clients that are sending requests too frequently, uncomment and edit # the following line. ! ratelimit interval 3 burst 8 ####################################################################### ### REPORTING BIG CLOCK CHANGES # Perhaps you want to know if chronyd suddenly detects any large error # in your computer's clock. This might indicate a fault or a problem # with the server(s) you are using, for example. # # The next option causes a message to be written to syslog when chronyd # has to correct an error above 0.5 seconds (you can use any amount you # like). ! logchange 0.5 # Django : 2027-02-18 logchange 0.5 # The next option will send email to the named person when chronyd has # to correct an error above 0.5 seconds. (If you need to send mail to # several people, you need to set up a mailing list or sendmail alias # for them and use the address of that.) ! mailonchange wibble@example.net 0.5 # Django : 2024-02-18 mailonchange django@nausch.org 0.5 ####################################################################### ### COMMAND ACCESS # The program chronyc is used to show the current operation of chronyd # and to change parts of its configuration whilst it is running. # By default chronyd binds to the loopback interface. Uncomment the # following lines to allow receiving command packets from remote hosts. ! bindcmdaddress 0.0.0.0 ! bindcmdaddress :: # Normally, chronyd will only allow connections from chronyc on the same # machine as itself. This is for security. If you have a subnet # 192.168.*.* and you want to be able to use chronyc from any machine on # it, you could uncomment the following line. (Edit this to your own # situation.) ! cmdallow 192.168/16 # You can add as many 'cmdallow' and 'cmddeny' lines as you like. The # syntax and meaning is the same as for 'allow' and 'deny', except that # 'cmdallow' and 'cmddeny' control access to the chronyd's command port. # Rate limiting can be enabled also for command packets. (Note, # commands from localhost are never limited.) ! cmdratelimit interval -4 burst 16 ####################################################################### ### HARDWARE TIMESTAMPING # On Linux, if the network interface controller and its driver support # hardware timestamping, it can significantly improve the accuracy of # synchronisation. It can be enabled on specified interfaces only, or it # can be enabled on all interfaces that support it. ! hwtimestamp eth0 ! hwtimestamp * ####################################################################### ### REAL TIME CLOCK # chronyd can characterise the system's real-time clock. This is the # clock that keeps running when the power is turned off, so that the # machine knows the approximate time when it boots again. The error at # a particular epoch and gain/loss rate can be written to a file and # used later by chronyd when it is started with the '-s' option. # # You need to have 'enhanced RTC support' compiled into your Linux # kernel. (Note, these options apply only to Linux.) ! rtcfile /var/lib/chrony/rtc # Your RTC can be set to keep Universal Coordinated Time (UTC) or local # time. (Local time means UTC +/- the effect of your timezone.) If you # use UTC, chronyd will function correctly even if the computer is off # at the epoch when you enter or leave summer time (aka daylight saving # time). However, if you dual boot your system with Microsoft Windows, # that will work better if your RTC maintains local time. You take your # pick! ! rtconutc # By default chronyd assumes that the enhanced RTC device is accessed as # /dev/rtc. If it's accessed somewhere else on your system (e.g. you're # using devfs), uncomment and edit the following line. ! rtcdevice /dev/misc/rtc # Alternatively, if not using the -s option, this directive can be used # to enable a mode in which the RTC is periodically set to the system # time, with no tracking of its drift. rtcsync ####################################################################### ### REAL TIME SCHEDULER # This directive tells chronyd to use the real-time FIFO scheduler with the # specified priority (which must be between 0 and 100). This should result # in reduced latency. You don't need it unless you really have a requirement # for extreme clock stability. Works only on Linux. Note that the "-P" # command-line switch will override this. ! sched_priority 1 ####################################################################### ### LOCKING CHRONYD INTO RAM # This directive tells chronyd to use the mlockall() syscall to lock itself # into RAM so that it will never be paged out. This should result in reduced # latency. You don't need it unless you really have a requirement # for extreme clock stability. Works only on Linux. Note that the "-m" # command-line switch will also enable this feature. ! lock_all # Django : 2024-02-18 lock_all
Die relevanten KOnfigurationsoptionen können wir mit Hilfe von grep
uns auch gerafft anzeigen lassen.
# grep -Ev '(^%|^$|^#|^!|^;)' /etc/chrony.conf
pool pool.ntp.org iburst driftfile /var/lib/chrony/drift ntsdumpdir /var/lib/chrony dumpdir /var/lib/chrony leapsectz right/UTC makestep 1.0 3 allow fd00::/10 allow 10.0.0.0/24 allow 2003:a:e0d:7603::/64 allow 192.168.0.0/24 allow 2003:a:e0d:7607::/64 local stratum 3 logchange 0.5 mailonchange django@nausch.org 0.5 rtcsync lock_all
Paketfilter - firewalld
Wie auch schon früher bei CentOS ab Release 7 bzw. den nachfolgenden Relaese-Kandidaten Stream von RHEL nutzen wir auch unter Arch Linux den dynamischen firewalld Service. Ein grosser Vorteil der dynamischen Paketfilterregeln ist unter anderem, dass zur Aktivierung der neuen Firewall-Regel(n) nicht der Daemon durchgestartet werden muss und somit alle aktiven Verbindungen kurz getrennt werden. Sondern unsere Änderungen können on-the-fly aktiviert oder auch wieder deaktiviert werden.
Damit unsere Clients Verbindungen zu dem geöffneten UDP-Port ntp/123 chrony-Daemons aufbauen können, müssen wir für diese noch Änderungen am Paketfilter firewalld vornehmen.
In folgendem Konfigurationsbeispiel gehen wir von einem Host aus, der zwei Firewall-Zonen hält, einmal die Zone idmz
und einmal die Zone intra
. in Beiden Zonen öffnen wir nun für die zugehörigen Netze den UDP-Port ntp/123.
Mit Hilfe des Programms firewall-cmd legen wir nun jeweils eine permanente Regel in der beiden Zonen idmz und intra an. Als Source-IP geben geben wir jeweils die Netze unserer Clients an. Genug der Vorrede, mit nachfolgendem Befehl wird der Port 123 geöffnet.
Paketfilter - firewalld
# firewall-cmd --permanent --zone=idmz --add-rich-rule="rule family="ipv4" source address="10.0.0.0/24" port protocol="udp" port="123" \ destination address="10.0.0.110/32" accept"
success
# firewall-cmd --permanent --zone=idmz --add-rich-rule="rule family="ipv6" source address="2003:a:e0d:7603::/64" port protocol="udp" port="123" \ destination address="2003:a:e0d:7603:10::110/64" accept"
success
# firewall-cmd --permanent --zone=idmz --add-rich-rule="rule family="ipv6" source address="fd00::/10" port protocol="udp" port="123" \ destination address="fd00::3:10:0:0:110/64" accept"
success
# firewall-cmd --permanent --zone=intra --add-rich-rule="rule family="ipv4" source address="192.168.0.0/24" port protocol="udp" port="123" \ destination address="192.168.0.110/32" accept"
success
# firewall-cmd --permanent --zone=intra --add-rich-rule="rule family="ipv6" source address="2003:a:e0d:7607::/64" port protocol="udp" port="123" \ destination address="2003:a:e0d:7607:1920:168:0:110/64" accept"
success
# firewall-cmd --permanent --zone=idmz --add-rich-rule="rule family="ipv6" source address="fd00::/10" port protocol="udp" port="123" \ destination address="fd00::7:192:168:0:110/64" accept"
success
Anschließend können wir den Firewall-Daemon einmal neu laden und anschließend überprüfen, ob die Regeln auch entsprechend unserer Definition, gezogen haben.
# firewall-cmd --reload
success
Werfen wir noch kurz einen Blick in die Zone idmz
:
# firewall-cmd --zone=idmz --list-rich-rules
rule family="ipv6" source address="2003:a:e0d:7603::/64" destination address="2003:a:e0d:7603:10::110/64" port port="123" protocol="udp" accept
rule family="ipv6" source address="fd00::/10" destination address="fd00::3:10:0:0:110/64" port port="123" protocol="udp" accept
rule family="ipv6" icmp-type name="echo-request" accept
rule family="ipv4" source address="10.0.0.0/24" destination address="10.0.0.110/32" port port="123" protocol="udp" accept
Bei Bedarf machen wir das gleiche nun noch mit der Zone intra
:
# firewall-cmd --zone=intra --list-rich-rules
rule family="ipv6" source address="2003:a:e0d:7607::/64" destination address="2003:a:e0d:7607:1920:168:0:110/64" port port="123" protocol="udp" accept rule family="ipv6" source address="2003:a:e0d:7607::/64" service name="ssh" accept rule family="ipv6" source address="fd00::/10" destination address="fe10::7:1921:68ff:fe00:110/64" port port="123" protocol="udp" accept rule family="ipv4" source address="192.168.0.0/24" destination address="192.168.0.110/32" port port="123" protocol="udp" accept rule family="ipv4" source address="10.0.10.0/24" service name="ssh" accept
Start des Daemon
manueller Start des Daemon
Möchten wir unseren Daemon starten, benutzen wir den folgenden Befehlsaufruf.
# systemctl start chronyd.service
Wollen wir den Status des Chrony-Daemon abfragen nutzen wir den gewohnten Aufruf:
# systemctl status chronyd.service
● chronyd.service - NTP client/server Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: disabled) Active: active (running) since Sun 2024-02-18 18:26:17 CET; 5s ago Docs: man:chronyd(8) man:chrony.conf(5) Process: 1863 ExecStart=/usr/bin/chronyd $OPTIONS (code=exited, status=0/SUCCESS) Main PID: 1865 (chronyd) Tasks: 1 (limit: 9510) Memory: 9.4M (peak: 9.9M) CPU: 74ms CGroup: /system.slice/chronyd.service └─1865 /usr/bin/chronyd Feb 18 18:26:17 vml000110 systemd[1]: Starting NTP client/server... Feb 18 18:26:17 vml000110 (chronyd)[1863]: chronyd.service: Referenced but unset environment variable evaluates to an empty string: OPTIONS Feb 18 18:26:17 vml000110 chronyd[1865]: chronyd version 4.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 -DEBUG) Feb 18 18:26:17 vml000110 chronyd[1865]: Frequency 24.000 +/- 0.079 ppm read from /var/lib/chrony/drift Feb 18 18:26:17 vml000110 chronyd[1865]: Using right/UTC timezone to obtain leap second data Feb 18 18:26:17 vml000110 systemd[1]: Started NTP client/server. Feb 18 18:26:22 vml000110 chronyd[1865]: Selected source 136.243.177.133 (pool.ntp.org) Feb 18 18:26:22 vml000110 chronyd[1865]: System clock TAI offset set to 37 seconds
Zur Anzeige des chronyd
spezifischen Protokolle, die der journald-Daemon gesammelt hat, verwenden Sie den Befehl journalctl
.
# journalctl -u chronyd
Feb 18 18:26:17 vml000110 systemd[1]: Starting NTP client/server... Feb 18 18:26:17 vml000110 (chronyd)[1863]: chronyd.service: Referenced but unset environment variable evaluates to an empty string: OPTIONS Feb 18 18:26:17 vml000110 chronyd[1865]: chronyd version 4.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 -DEBUG) Feb 18 18:26:17 vml000110 chronyd[1865]: Frequency 24.000 +/- 0.079 ppm read from /var/lib/chrony/drift Feb 18 18:26:17 vml000110 chronyd[1865]: Using right/UTC timezone to obtain leap second data Feb 18 18:26:17 vml000110 systemd[1]: Started NTP client/server. Feb 18 18:26:22 vml000110 chronyd[1865]: Selected source 136.243.177.133 (pool.ntp.org) Feb 18 18:26:22 vml000110 chronyd[1865]: System clock TAI offset set to 37 seconds
automatischer Start des Daemon
Damit der Daemon chrony automatisch bei jedem Systemstart startet, kann die Einrichtung eines Start-Scriptes über folgenden Befehl erreicht werden:
# systemctl enable chronyd.service
ln -s '/usr/lib/systemd/system/chronyd.service' '/etc/systemd/system/multi-user.target.wants/chronyd.service'
Ein Überprüfung ob der Dienst (Daemon)chrony wirklich bei jedem Systemstart automatisch mit gestartet wird, kann durch folgenden Befehl erreicht werden:
# systemctl is-enabled chronyd.service
enabled
Tests
Daemon
Als ersten Test überprüfen wir, ob der Service chronyd geladen und ausgeführt wird. Hierzu benutzen wir folgenden Befehl.
# systemctl status chronyd.service
# systemctl status chronyd.service
● chronyd.service - NTP client/server Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: disabled) Active: active (running) since Sun 2024-02-18 18:26:17 CET; 5s ago Docs: man:chronyd(8) man:chrony.conf(5) Process: 1863 ExecStart=/usr/bin/chronyd $OPTIONS (code=exited, status=0/SUCCESS) Main PID: 1865 (chronyd) Tasks: 1 (limit: 9510) Memory: 9.4M (peak: 9.9M) CPU: 74ms CGroup: /system.slice/chronyd.service └─1865 /usr/bin/chronyd Feb 18 18:26:17 vml000110 systemd[1]: Starting NTP client/server... Feb 18 18:26:17 vml000110 (chronyd)[1863]: chronyd.service: Referenced but unset environment variable evaluates to an empty string: OPTIONS Feb 18 18:26:17 vml000110 chronyd[1865]: chronyd version 4.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 -DEBUG) Feb 18 18:26:17 vml000110 chronyd[1865]: Frequency 24.000 +/- 0.079 ppm read from /var/lib/chrony/drift Feb 18 18:26:17 vml000110 chronyd[1865]: Using right/UTC timezone to obtain leap second data Feb 18 18:26:17 vml000110 systemd[1]: Started NTP client/server. Feb 18 18:26:22 vml000110 chronyd[1865]: Selected source 136.243.177.133 (pool.ntp.org) Feb 18 18:26:22 vml000110 chronyd[1865]: System clock TAI offset set to 37 seconds
Betreiben wir den chronyd im Client-Modus, wird kein Port 123 bedient - daher wird bei der nachfolgenden Abfrage auch kein geöffneter Port 123 gemeldet.
# ss -tulpn | grep 123
Betreiben wir unseren chrony Daemon im Servermode wird dann natürlich der Port 123 auf den konfigurierten Netzwerkadressen gebunden.
# ss -paunt
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process udp UNCONN 0 0 0.0.0.0:123 0.0.0.0:* users:(("chronyd",pid=1865,fd=7)) udp UNCONN 0 0 127.0.0.1:323 0.0.0.0:* users:(("chronyd",pid=1865,fd=5)) udp UNCONN 0 0 [::]:123 [::]:* users:(("chronyd",pid=1865,fd=8)) udp UNCONN 0 0 [::1]:323 [::]:* users:(("chronyd",pid=1865,fd=6))
Paketfilter - Port Erreichbarkeit
Bevor wir nun von einem unserer Client-Hosts, die zur Synchronisation der Uhrzeit unseren eigenen NTP-Server nutzen, mit Hilfe des Binary chronyc
einzelne Tests durchführen, testen wir noch ob überhaupt der Port 123 auf unserer VM auf der der chronyd läuft errechbar ist. Dazu benutzen wir das Programm nmap
.
Zunächst installieren wir uns besagtes Programm-Paket, sofern es noch nichtv auf unsererm Client-Rechner vorhanden ist. Nachfolgend finden wir die Variante der Installation unter Arch Linux mit Root-Rechten. Verwenden wir einen User ohne Root-Rechte, stellen wir einfach ein sudo
dem Aufriuuf voran. Bei anderen Distributionen verwenden wir entsprechend den zugehörigen Paketmanager.
# pacman -S nmap
Zunächst testen wir ob wir per IPv4
den UDP
-Port 123
(NTP) auf dem Zielhost 10.0.0.110
, auf dem unser chronyd
als NTP-Server fungiert, erreichbar ist.
# nmap -4 -sU -v -p 123 10.0.0.110
Starting Nmap 7.94 ( https://nmap.org ) at 2024-02-21 18:33 CET Initiating ARP Ping Scan at 18:33 Scanning 10.0.0.110 [1 port] Completed ARP Ping Scan at 18:33, 0.06s elapsed (1 total hosts) Initiating Parallel DNS resolution of 1 host. at 18:33 Completed Parallel DNS resolution of 1 host. at 18:33, 0.00s elapsed Initiating UDP Scan at 18:33 Scanning 10.0.0.110 [1 port] Discovered open port 123/udp on 10.0.0.110 Completed UDP Scan at 18:33, 0.14s elapsed (1 total ports) Nmap scan report for 10.0.0.110 Host is up (0.00044s latency). PORT STATE SERVICE 123/udp open ntp MAC Address: 52:54:00:41:11:01 (QEMU virtual NIC) Read data files from: /usr/bin/../share/nmap Nmap done: 1 IP address (1 host up) scanned in 0.32 seconds Raw packets sent: 3 (180B) | Rcvd: 2 (104B)
Soweit so gut, das hat also schon mal geklappt!
Im nächsten Schritt versuchen wir ob wir Port 123
UDP
per IPv6
die ULA1) fd00::3:10:0:0:110
kontaktieren können.
# nmap -6 -sU -v -p 123 fd00::3:10:0:0:110
Starting Nmap 7.94 ( https://nmap.org ) at 2024-02-21 18:38 CET Initiating ND Ping Scan at 18:38 Scanning fd00::3:10:0:0:110 [1 port] Completed ND Ping Scan at 18:38, 0.06s elapsed (1 total hosts) Initiating Parallel DNS resolution of 1 host. at 18:38 Completed Parallel DNS resolution of 1 host. at 18:38, 0.00s elapsed Initiating UDP Scan at 18:38 Scanning fd00::3:10:0:0:110 [1 port] Discovered open port 123/udp on fd00::3:10:0:0:110 Completed UDP Scan at 18:38, 0.14s elapsed (1 total ports) Nmap scan report for fd00::3:10:0:0:110 Host is up (0.00052s latency). PORT STATE SERVICE 123/udp open ntp MAC Address: 52:54:00:41:11:01 (QEMU virtual NIC) Read data files from: /usr/bin/../share/nmap Nmap done: 1 IP address (1 host up) scanned in 0.32 seconds Raw packets sent: 3 (264B) | Rcvd: 2 (168B)
Auch das wurde entsprechend positiv beschieden PORT → 123/udp, STATE → open, SERVICE → ntp
.
Zum Schluß testen wir dann noch die Variante mit der IPv6-Unicast-Adresse 2003:a:e0d:7603:10::110
unseres eignen NTP-Servers.
# nmap -6 -sU -v -p 123 2003:a:e0d:7603:10::110
Starting Nmap 7.94 ( https://nmap.org ) at 2024-02-21 18:41 CET Initiating ND Ping Scan at 18:41 Scanning 2003:a:e0d:7603:10::110 [1 port] Completed ND Ping Scan at 18:41, 0.06s elapsed (1 total hosts) Initiating Parallel DNS resolution of 1 host. at 18:41 Completed Parallel DNS resolution of 1 host. at 18:41, 0.00s elapsed Initiating UDP Scan at 18:41 Scanning vml000110.idmz.nausch.org (2003:a:e0d:7603:10::110) [1 port] Discovered open port 123/udp on 2003:a:e0d:7603:10::110 Completed UDP Scan at 18:41, 0.14s elapsed (1 total ports) Nmap scan report for vml000110.idmz.nausch.org (2003:a:e0d:7603:10::110) Host is up (0.00053s latency). PORT STATE SERVICE 123/udp open ntp MAC Address: 52:54:00:41:11:01 (QEMU virtual NIC) Read data files from: /usr/bin/../share/nmap Nmap done: 1 IP address (1 host up) scanned in 0.32 seconds Raw packets sent: 3 (264B) | Rcvd: 2 (168B)
Auch dieser Test war entsprechend erfolgreich! Somit können wir uns nun im Anschluss mit dem Binary chronyc
und dem Testen unseres chrony-Daemon befassen.
Checking chrony Sources
Welche Server vom lokalen Daemon benutzt werden kann mit Hilfe des Befehls chronyc sources
abgefragt werden.
# chronyc sources
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* defiant.tlercher.de 2 10 377 91 +59us[ +988us] +/- 10ms
Mit der Option -v
erhalten wir dazu auch noch Hinweise zu den einzelnen Spaten und deren Werte bzw. Bedeutung:
# 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
===============================================================================
^+ time.cnetm.de 2 6 377 7 +755us[ +755us] +/- 17ms
^- frank.askja.de 2 6 377 5 -166us[ -166us] +/- 59ms
^* ntp1.noris.net 2 6 377 72 -154us[ -125us] +/- 12ms
^+ sv1.ggsrv.de 2 6 377 5 +284us[ +284us] +/- 15ms
Dieses Beispiel zeigt die Abfrage auf unserem zentralen NTP-Server, den wir gerade eingerichtet haben. Nachfolgendes Beispiel zeigt einen Host, der wiederum unseren eigenen zentralen NTP-Server als Quelle benutzt.
.-- 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
===============================================================================
^+ fd00::3:10:0:0:110 3 6 377 30 +92us[ +306us] +/- 11ms
^* vml000110.idmz.nausch.org 3 6 377 24 +86us[ +301us] +/- 11ms
^+ 10.0.0.110 3 6 377 30 +87us[ +302us] +/- 11ms
Die einzelnen Spalten haben folgende Bedeutung:
- M
Zeigt den Modus der Angezeigten Quelle,- ^ steht für einen NTP-Server,
- = steht für einen Peer-Rechner und
- # steht für eine lokal am Host angeschlossene Referenzuhr.
- S
Zeigt den Status der Zeitquelle an- * bedeutet, der chrony-Daemon hat sich mit der Quelle synchronisiert.
- + die Quelle wird als akzeptabl gewertet, die mit der ausgewählten Quelle kombiniert wird.
- - steht für eine akzeptable Quelle, die aber durch die Kombinationsalgorithmus ausgeschlossen wird.
- ? bedeutet, dass die Verbindung lückenhaft war bzw. abgebrochen ist oder dessen UDP-Pakete nicht alle Tests bestanden haben.
- x definiert eine fehlerhafte Quelle, deren Zeitangaben nicht mit den anderen Quellen nicht im Einklang gebracht werden können.
- ~ steht für eine Quelle mit großen Schwankungen und
- ? Anzeige, dass der Daemon gerade erst gestartet wurde und weniger als 4 Datenpakete empfangen wurden.
- Name/IP address
Zeigt den Namen bzw. die IP-Adresse der Quelle, Referenz-ID oder der lokalen Referenz-Uhr. - Stratum
Anzeige des Stratum-Wertes von der Quelle an Hand der zuletzt empfangenen Datenpakete.- 1 wird angezeigt, wenn der Server über eine lokal angeschlossene Referenzuhr verfügt.
- 2 wird angezeigt, wenn der Daemon sich mit einer Quelle synchronisiert hat, die den Wert Stratum 1 inne hat.
- n Jede weitere Erhöhung des Stratum-Wertes bedeutet, dass ein weiterer Host zwischen dem chrony-Daemon und dem Zeitnormal mit dem Stratum Wert 1 steht.
- Poll
Angabe in welchen Abständen die Uhrzeit turnusmäßig synchronisiert wird. Die Zeitspanne errechnet sich bei einem polling-Wert n = 6 nach (2n) von 26 = 64. Der Wert kann schwanken, je nach dem wie stabil das Zeitnormal verläuft. - Reach
Registerwert (Oktalzahl) der empfangenen Datenpakete. Das Register hat hat 8 bit und wird jeweils beim Empfang bzw. etwaigen Verlusten von Datenpaketen angepasst. Ein Wert von 377 zeigt z.B. an, das die letzten acht empfangenen Datenpakete gültig waren. - LastRx
In dieser Spalte wird angezeigt, wann zuletzt von der genannten Zeitquelle ein Datenpaket empfangen wurde. Ein reiner Zahlenwert steht für die Angabe in Sekunden, sowie die Buchstaben m, h, d oder y jeweils für Minuten, Stunden, Tage bzw. Jahre. Der Wert 10 Jahre steht dafür, dass noch kein gültiges Datenpaket von der Quelle empfangen wurde. - Last sample
Hier wird der Offset zwischen der lokalen Zeit und dem empfangenen NTP-UDP-Paket des Zeitservers angezeigt. Der Wert in den eckigen Klammern zeigt die tatsächlich gemessene Abweichung (Offset). Die Werte werden in den Einheiten ns für Nanosekunden, us für Mikrosekunden, ms für Millisekunden und s für Sekunden angegeben. Die Zahl auf der linken Seite der eckigen Klammern zeigt die ursprünglichen Messwert an, mit dem die Messwerte bis jetzt korrigiert wurden. Die Zahl nach dem +/- Anzeige zeigt die Fehlerspanne bei der Messung. Positive Offsets anzuzeigen, dass die lokale Zeit der NTP-Serverzeit vorausläuft.
Haben wir uns mit chronyc verbunden, können wir uns auch mit der Option -v eine Beschreibung der Spalten abrufen.
# chronyc -a
chrony version 4.5 Copyright (C) 1997-2003, 2007, 2009-2023 Richard P. Curnow and others chrony comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See the GNU General Public License version 2 for details. chronyc>
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
===============================================================================
^+ time.cnetm.de 2 6 377 7 +755us[ +755us] +/- 17ms
^- frank.askja.de 2 6 377 5 -166us[ -166us] +/- 59ms
^* ntp1.noris.net 2 6 377 72 -154us[ -125us] +/- 12ms
^+ sv1.ggsrv.de 2 6 377 5 +284us[ +284us] +/- 15ms
Checking chrony Source Statistics
Den Status unserer Zeitserverquellen fragen wir mit dem Befehl chronyc sourcestats ab.
# chronyc sourcestats
Name/IP Address NP NR Span Frequency Freq Skew Offset Std Dev
==============================================================================
time.cnetm.de 16 11 782 -0.042 1.299 -35us 292us
frank.askja.de 16 9 783 +0.281 0.379 +169us 99us
ntp1.noris.net 6 4 452 -0.529 0.977 -304us 43us
sv1.ggsrv.de 14 8 784 +0.211 0.264 +434us 70us
Mit der Option -v
erhalten wir eine Kurzbeschreibung der angezeigten Werte.
# chronyc sourcestats -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
==============================================================================
time.cnetm.de 16 11 782 -0.042 1.299 -37us 292us
frank.askja.de 16 9 783 +0.281 0.379 +178us 99us
ntp1.noris.net 6 4 452 -0.529 0.977 -320us 43us
sv1.ggsrv.de 14 8 784 +0.211 0.264 +440us 70us
Die einzelnen Spalten haben folgende Bedeutung:
- Name / IP-Adresse
Name bzw. die IP-Adresse der Quelle, Referenz-ID oder der lokalen Referenz-Uhr auf den/die sich die folgenden Werte beziehen. - NP
Anzahl der Abtastpunkte (sampling points), die derzeit vom Daemon verwendet werden. Die Driftrate und der Offset werden durch eine lineare Regression der Abtastpunkte geschätzt. - NR
Anzahl der Durchläufe der Restwertberechnungen mit dem gleichen Vorzeichen nach der letzten Regression. Sobald dieser wert unter die Anzahl der Abtastpunkte (sampling points) ist dies ein Anzeichen, dass die Werte nicht mehr optimal linear berechnet werden können. Wird die Anzahl der Durchläufe zu klein, führt chronyd basieren auf alte bekannte Daten eine neu Regression durch, bis der wert wieder in einem akzeptablen Bereich liegt. - Span
Abstand zwischen dem ältesten und neuesten Sample. Wird keine Einheit angegeben, werden Sekunden angezeigt; m steht für Minuten. - Frequency
geschätzte Restfrequenz, die dedr Daemon nutzte (10-6) - Freq Skew
geschätzte Fehlergrenzen des Werts Frequency (10-6). - Offset
geschätzter Offset der Quelle. - Std Dev
geschätzte Standardabweichung der Stichprobe.
Haben wir uns mit chronyc verbunden, können wir uns auch mit der Option -v eine Beschreibung der Spalten abrufen.
# chronyc -a
chrony version 4.5 Copyright (C) 1997-2003, 2007, 2009-2023 Richard P. Curnow and others chrony comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See the GNU General Public License version 2 for details. chronyc>
chronyc> sourcestats -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
==============================================================================
fd00::3:10:0:0:110 6 3 516 +0.712 4.486 +87us 185us
vml000110.idmz.nausch.org 6 3 389 -0.745 4.072 -107us 109us
10.0.0.110 6 3 387 +0.011 6.874 +20us 151us
Checking chrony Tracking
Die Anzeige der System Zeit Informationen fragen wir mit dem Befehl chronyc tracking ab.
# chronyc tracking
Reference ID : 3E800112 (ntp1.noris.net) Stratum : 3 Ref time (UTC) : Thu Feb 22 12:24:14 2024 System time : 0.000030264 seconds slow of NTP time Last offset : +0.000049906 seconds RMS offset : 0.000355495 seconds Frequency : 23.667 ppm fast Residual freq : +0.017 ppm Skew : 0.322 ppm Root delay : 0.016084936 seconds Root dispersion : 0.002525240 seconds Update interval : 64.5 seconds Leap status : Normal
Die einzelnen Werte haben nachfolgend aufgeführte Bedeutungen:
- Reference ID
Referenz-ID bzw. Name und die IP-Adresse mit dem sich der chrony-Daemon synchronisiert hat. Der Wert 127.127.1.1 zeigt an, dass sich der Daemon nicht mit einer externen NTP-server synchronisiert hat, sondern dass der Daemon im „lokal mode“ befindet, da der Server über eine externe Signalquelle z.B. einer DCF 77 Funkuhr verfügt. - Stratum
Anzeige des Stratum-Wertes von der Quelle an Hand der zuletzt empfangenen Datenpakete.- 1 wird angezeigt, wenn der Server über eine lokal angeschlossene Referenzuhr verfügt.
- 2 wird angezeigt, wenn der Daemon sich mit einer Quelle synchronisiert hat, die den Wert Stratum 1 inne hat.
- n Jede weitere Erhöhung des Stratum-Wertes bedeutet, dass ein weiterer Host zwischen dem chrony-Daemon und dem Zeitnormal mit dem Stratum Wert 1 steht.
- Ref time (UTC)
Uhrzeit (UTC) der Referenz ID, also der Zeit des externen Zeitservers oder der lokalen externen Uhr. - System time
Im normalen Betrieb wird der chrony-Daemon die lokale Zeit nicht in einem Schritt neu stellen, da dies zu ungewollten Effekten führen würde. Chrony word daher zur Anpassung der lokalen Uhrzeit an das externe Ziel durch Veränderungen der Laufgeschwindigkeit der lokalen Uhr anpassen; d.h. die loakel Uhr wird mal schneller oder langsamer als die Uhr des Zeitquelle laufen. Diese Abweichung wird beim Punkt Ref time (UTC) angegeben. - Last offset
Repräsentiert die geschätze Differenz der lokalen Uhr zur externen Quelle. - RMS offset
Dies ist die Anzeige der durchschnittliche Abweichung der lokalen Uhr zur externen Quelle. - Frequency
Abweichung der lokalen Uhrzeit vom Zeitnormal, in der Annahme chronyd würde die Zeit nicht anpassen. Der Wert wird in ppm2) angegeben. - Residual freq
Anzeige der Restfrequenz (residual frequency) für die aktuell ausgewählte Referenzquelle. Der angezeigte Wert spiegelt einen Unterschied zwischen dem, was die Messung von der Referenzquelle vorgibt un der aktuell von chrony-Daemon verwendeten Frequenz wieder. Der Wert wird dabei niemals den Wert 0 anzeigen, da bei der Berechnung der Frequenzwerte Rundungen verwendet werden. Jedes mal wenn der Frequenzwert des Zeitnormals empfangen wurde und die neue Restfrequenz berechnet wurde, wird die geschätzte Genauigkeit dieses neuen Restwertes mit den vorhandenen Werten verglichen und angezeigt. Je genauer die Messungen der Referenzquelle ist und je stabiler die lokale Uhr läuft um so geringer wird der angezeigte Wert und nähert sich im Idealfall dem Wert 0 an. - Skew
Frequenzdrifft in ppm3). - Root delay
Verzögerung durch Laufzeitunterschiede zwischen dem Straum 1 und dem lokalen Server, die durch Laufzeitunterschiede im Netzwerk aufgetreten sind. - Root dispersion
Ungefähre Abweichung (Streuung), bedingt durch statistischen Messschwankungen oder Rundungsdifferenzen, der lokalen Uhrzeit bis hin zur Stratum 1 Quelle. - Update interval
Intervall in Sekunden, in der der Daemon die Uhrzeit spätentens aktualisiert. - Leap status
Sprungstatus der Uhrzeit, die einen der folgenden Werte aufweisen kann:- Normal normaler Betrieb, also alles in Ordnung,
- Insert second Zeit wurde durch Einfügen einer Sekunde verlangsamt,
- Delete second Zeit wurde durch Löschen einer Sekunde beschleunigt, oder
- Not synchronized Zeit konnte noch nicht synchronisiert werden.
Checking chrony Clients
Betreiben wir unseren chrony-Daemon im Server-Mode, können wir uns anzeigen lassen, welcher oder welche Clients sich mit dem Daemon verbunden haben, egal ob via NTP oder zum command/monitoring Port. Hierzu öffnen wir zuerst einmal die chrony-Shell auf unserem Server, auf dem der chrony-Daemon läuft.
# chronyc -a
chrony version 4.5 Copyright (C) 1997-2003, 2007, 2009-2023 Richard P. Curnow and others chrony comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See the GNU General Public License version 2 for details. chronyc>
Anschliessend fragen wir mit dem Befehl clients ab, welche Clients sich mit dem Server verbunden haben.
chronyc> clients
Hostname NTP Drop Int IntL Last Cmd Drop Int Last =============================================================================== fd00::3:10:0:0:210 115 0 7 - 50 0 0 - - _gateway 110 0 6 - 50 0 0 - - 2003:a:e0d:7603:10::210 71 0 6 - 42 0 0 - -
Die einzelnen Werte haben nachfolgend aufgeführte Bedeutungen:
- Hostname
Hostname oder IP-Adresse des Clients - Client
Anzahl der Verbindungen des Clients im NTP client mode - Peer
Anzahl der Verbindungen des Clients im NTP symmetric active mode - CmdAuth
Anzahl der authentifizierten Steuerpakete die vom Client bis jetzt erfolgreich, d.h. nach dem password-Befehl, abgesetzt wurden. - CmdNorm
Anzahl der nicht authentifizierten Steuerpakete die vom Client bis jetzt abgesetzt wurden. - CmdBad
Anzahl der erfolglosen Versuche Steuerpakete die vom Client bis jetzt abgesetzt wurden. - LstN
Zeit seit dem das letzte NTP Pakete empfangen wurde - LstC
Zeit seit dem das letzte Steuerpaket/Befehl empfangen wurde
Orchestrierung - Installation und Konfiguration des chronyd mit Hilfe von Ansible
Natürlich wird man im Jahr 2024 nicht mehr ernsthaft, manuell Server aufsetzen und betreiben wollen. Vielmehr wird man auf ein Orchestrierungswerkzeug wie z.B. Ansible zurückgreifen.
Wir werden uns nun nachfolgend sowohl die Client- wie auch die Server-Installation und -konfiguration genauer betrachten.
Installation und Client-Konfiguration
Setzen wir einen neue virtuellen Host unter Arch Linux neu auf, oder wollen wir bei einem bestehenden Host die Konfiguration aktualisieren, verwenden wir wie zuvor schon angeschnitten Ansible als Orchestrierungswerkzeug. So ist sichergestellt dass zum einen all unsere Hosts entsprechend gleich aufgebaut, konfiguriert und betrieben werden.
Rolle
Für die Konfiguration unserer Hosts verwenden wir eine eigene Rolle chrony_client
, die wir dann in einem unserer Playbooks später einfach mit aufrufen werden.
$ tree roles/chrony_client/
roles/chrony_client/ ├── defaults ├── files ├── handlers ├── library ├── lookup_plugins ├── meta ├── module_utils ├── tasks │ ├── chrony.yml │ └── main.yml ├── templates └── vars
Wie wir sehen ist die Rolle durchaus überschaubar, im Task main.yaml
verweisen wir lediglich auf den eigentlichen Task chrony.yml
.
$ vim ~/ansible/roles/chrony_client/tasks/main.yml
- roles/chrony_client/tasks/main.yml
--- # Playbook/Rolle zur Konfiguration des NTP-Clients - include_tasks: chrony.yml # Chrony Client installieren und konfigurieren. tags: chrony # ... # YML Ende
Die eigentliche Installation und Konfiguration erfolgt dann im Task chrony.yml
.
$ vim ~/ansible/roles/chrony_client/tasks/chrony.yml
- roles/chrony_client/tasks/chrony.yml
--- # YAML Start # Chrony Daemon installieren und als Client konfigurieren. - name: "Installation des chrony-Daemons." community.general.pacman: name: chrony state: present - name: "Checken ob es bereits eine Backupdatei der chrony.conf gibt." ansible.builtin.stat: path: /etc/chrony.conf.orig register: check_chrony_config - name: "Sofern bereits eine Backupdatei der chrony.conf existiert, diese rücksichern." ansible.builtin.copy: remote_src: true src: /etc/chrony.conf.orig dest: /etc/chrony.conf owner: root group: root mode: '0644' when: check_chrony_config.stat.exists - name: "Backupdatei der chrony.conf Konfigurationsdatei erstellen." ansible.builtin.copy: remote_src: true src: /etc/chrony.conf dest: /etc/chrony.conf.orig owner: root group: root mode: '0644' when: not check_chrony_config.stat.exists - name: "Änderungen an der chrony.conf mit blockinfile vornehmen." ansible.builtin.blockinfile: path: /etc/chrony.conf marker: '# {mark} ANSIBLE MANAGED - DO NOT EDIT BLOCK' insertbefore: BOF block: | # Ansible managed configuration file, do not modify manually! - name: "Änderungen an der chrony.conf mit lineinfile vornehmen." ansible.builtin.lineinfile: dest: /etc/chrony.conf regexp: '{{ item.from }}' line: '{{ item.to }}' state: present backrefs: false with_items: '{{ chrony_config }}' - name: "Sicherstellen, dass der chrony Service reboot(-fest) startet." ansible.builtin.systemd: name: chronyd # state: reloaded enabled: true ... # YML Ende
Inventory -Variablendefinition
Über die Variable chrony_config
definieren wir nun im Inventory entweder in den Host- oder Group-Variablen welchen NTP-Server bzw. welchen NTP-Pool wir verwenden möchten. In Nachfolgendem Beispiel setzen wir für alle Host der Zone edmz als NTP-Server die Host-IP-Adressen fd00::3:10:0:0:110
, 2003:a:e0d:7603:10::110
und 10.0.0.110
. Ferner setzen wir noch als Empfangs-eMail-Adresse die unseres Hauptadmins, falls chronyd einen Fehler von mehr als 0,5 Sekunden korrigieren muss.
$ vim inventories/production/group_vars/edmz/chrony
- inventories/production/group_vars/edmz/chrony
chrony_config: - from: 'pool 2.arch.pool.ntp.org iburst' to : | server fd00::3:10:0:0:110 iburst server 2003:a:e0d:7603:10::110 iburst server 10.0.0.110 iburst - from: '! mailonchange wibble@example.net 0.5' to : mailonchange django@nausch.org 0.5
Playbook
Die definierte Rolle chrony_client binden wird dann z.B. in das Playbook für die Installation und Konfiguration des chrony-Daemon im Client-Mode ein.
# vim playbooks/arch_chrony_client.yml
- playbooks/arch_chrony_client.yml
--- # Ansible Playbook zum Konfigurieren des Chrony-Daemon im Client-Modus unter Arch-Linux. # Aufruf via $ ansible-playbook playbooks/arch_chrony_client.yml --limit <-VHOSTNAME->, also z.B.: # $ ansible-playbook playbooks/arch_chrony_client.yml --limit vml000210 # für einen Host aus der Hostgruppe DMZ. - name: arch_chrony_client.yml # Name des Playbooks hosts: idmz:edmz:intra # Hostgruppe für die das Playbook gelten soll roles: - role: chrony_client # Chrony-Client installieren und konfigurieren tags: chrony_client # Tag-Kennzeichnung der definierten Rolle ...
Playbooklauf
Die orchestrierte Variante der Installation und Konfiguration unseres chrony-Daemon im Client-Mode gestaltet sich ab sofort sehr einfach, brauchen wir doch lediglich die Konfigurationswerte im Inventory zu hinterlegen und zu pflegen und letztendlich das Playbook entsprechend aufzurufen:
$ ansible-playbook playbooks/arch_chrony_client.yml --limit vml000210
[19:32:35] Gathering Facts ↳ vml000210 | SUCCESS | 1.81s [19:32:37] chrony_client : include_tasks ↳ vml000210 | SUCCESS | 21ms [19:32:37] ↳ chrony: Installation des chrony-Daemons. ↳ vml000210 | SUCCESS | 1.34s [19:32:38] ↳ chrony: Checken ob es bereits eine Backupdatei der chrony.conf gibt. ↳ vml000210 | SUCCESS | 713ms [19:32:39] ↳ chrony: Sofern bereits eine Backupdatei der chrony.conf existiert, diese rücksichern. ↳ vml000210 | CHANGED | 661ms [19:32:40] ↳ chrony: Backupdatei der chrony.conf Konfigurationsdatei erstellen. vml000210 | SKIPPED | 31ms [19:32:40] ↳ chrony: Änderungen an der chrony.conf mit blockinfile vornehmen. ↳ vml000210 | CHANGED | 616ms [19:32:41] ↳ chrony: Änderungen an der chrony.conf mit lineinfile vornehmen. ↳ vml000210 | CHANGED | 1.18s [19:32:42] ↳ chrony: Sicherstellen, dass der chrony Service reboot(-fest) startet. ↳ vml000210 | SUCCESS | 984ms [19:32:43] system -- Play recap -- vml000210 : ok=8 changed=3 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
Installation und Chrony-Server-Konfiguration
Damit unsere eigenen neue virtuellen Host unter Arch Linux die Zeit von unserem eigenen NTP-Server holen können werden wir nun im nächsten Konfigurationsbeispiel mit Hilfe von Ansible chrony installieren und als NTP-Server konfigurieren.
Rollen
Chrony
Da sich die Installation und Konfiguration unseres chrony im Daemon-Modus lediglich bei den Konfigurationsparametern unterscheidet, können wir die Rolle aus dem vorherigen Beispiel einfach aufgreifen und wiederverwenden!
$ tree roles/chrony_client/
Wie wir sehen ist die Rolle durchaus überschaubar, im Task main.yaml
verweisen wir lediglich auf den eigentlichen Task chrony-.yml
.
$ vim ~/ansible/roles/chrony_client/tasks/main.yml
roles/chrony_client/tasks/main.yml
Die eigentliche Installation und Konfiguration erfolgt dann im Task chrony.yml
.
$ vim ~/ansible/roles/chrony_client/tasks/chrony.yml
Firewalld - Paketfilter
Der eigentliche „große“ Unterschied zwischen Client- und Daemon-Mode bei unserer chrony-Konfiguration ist der Umstand, dass wir auf unserem NTP-Server mit Hilfe des Firewall-Daemon firewalld
noch die Verkehrsbeziehungen freischalten und den Port 123/UDP
für die betreffenden Netze freischalten werden.
Diese Konfiguration lagern wir in einer eigenen Rolle aus, da diese ja bei Hosts, die den chronyd lediglich als Client nutzen nicht benötigt wird.
Da sich die Installation und Konfiguration unseres chrony im Daemon-Modus lediglich bei den Konfigurationsparametern unterscheidet, können wir die Rolle aus dem vorherigen Beispiel einfach aufgreifen und wiederverwenden!
Für die Konfiguration der Paketfilterregeln unseres NTP-Serversverwenden wir eine eigene Rolle chrony_firewalld, die wir dann in einem unserer Playbooks später einfach mit aufrufen werden.
$ tree roles/chrony_firewalld/
roles/chrony_firewalld/ ├── defaults ├── files ├── handlers ├── library ├── lookup_plugins ├── meta ├── module_utils ├── tasks │ ├── config.yml │ └── main.yml ├── templates └── vars
Wie wir sehen ist die Rolle durchaus überschaubar, im Task main.yaml
verweisen wir lediglich auf den eigentlichen Task chrony-.yml
.
$ vim ~/ansible/roles/chrony_firewalld/tasks/main.yml
- roles/chrony_firewalld/tasks/main.yml
--- # Playbook/Rolle zur Konfiguration des firewalld - include_tasks: config.yml # firewall konfigurieren. tags: config # ... # YML Ende
Die eigentliche Konfiguration unserer notwendigen Firewall-Regeln erfolgt dann im Task config.yml
.
$ vim ~/ansible/roles/chrony_firewalld/tasks/config.yml
- roles/chrony_firewalld/tasks/config.yml
-- # YAML Start # Firewall Daemon Regeln für chrony im Daemon-Mode konfigurieren. - name: "Port 123/UDP für IPv4 in der Zone IDMZ freischalten." ansible.posix.firewalld: rich_rule: > rule family=ipv4 source address={{ guest_ip4_net_1 }}{{ guest_mask4_1 }} port protocol="udp" port="123" destination address={{ guest_ip4_1 }}/32 accept zone: '{{ guest_zone_1 }}' immediate: true permanent: true state: enabled - name: "Port 123/UDP für IPv6 (ULA) in der Zone IDMZ freischalten." ansible.posix.firewalld: rich_rule: > rule family=ipv6 source address=fd00::/10 port protocol="udp" port="123" destination address={{ guest_ip6_ls_1 }}{{ guest_mask6_1 }} accept zone: '{{ guest_zone_1 }}' immediate: true permanent: true state: enabled - name: "Port 123/UDP für IPv6 (Global-Scope) in der Zone IDMZ freischalten." ansible.posix.firewalld: rich_rule: > rule family=ipv6 source address={{ guest_ip6_net_1 }}{{ guest_mask6_1 }} port protocol="udp" port="123" destination address={{ guest_ip6_gs_1 }}{{ guest_mask6_1 }} accept zone: '{{ guest_zone_1 }}' immediate: true permanent: true state: enabled - name: "Port 123/UDP für IPv4 in der Zone INTRA freischalten." ansible.posix.firewalld: rich_rule: > rule family=ipv4 source address={{ guest_ip4_net_2 }}{{ guest_mask4_2 }} port protocol="udp" port="123" destination address={{ guest_ip4_2 }}/32 accept zone: '{{ guest_zone_2 }}' immediate: true permanent: true state: enabled - name: "Port 123/UDP für IPv6 (ULA) in der Zone INTRA freischalten." ansible.posix.firewalld: rich_rule: > rule family=ipv6 source address=fd00::/10 port protocol="udp" port="123" destination address={{ guest_ip6_ls_2 }}{{ guest_mask6_2 }} accept zone: '{{ guest_zone_2 }}' immediate: true permanent: true state: enabled - name: "Port 123/UDP für IPv6 (Global-Scope) in der Zone INTRA freischalten." ansible.posix.firewalld: rich_rule: > rule family=ipv6 source address={{ guest_ip6_net_2 }}{{ guest_mask6_2 }} port protocol="udp" port="123" destination address={{ guest_ip6_gs_2 }}{{ guest_mask6_2 }} accept zone: '{{ guest_zone_2 }}' immediate: true permanent: true state: enabled - name: "Regeländerungen auf vml000110 neu laden." ansible.builtin.service: name: firewalld state: reloaded ... # YML Ende
Inventory -Variablendefinition
chronyd
Über die Variable chrony_config
definieren wir nun im Inventory in den Host-Variablen alle Konfigurationsparameter, die wir bei unserem NTP-Server bzw. genauer gesagt bei unserem chronyd im Server-Modesetzen wollen.
$ vim inventories/production/host_vars/vml010110/chrony
- inventories/production/host_vars/vml010110/chrony
chrony_config: - from: 'pool 2.arch.pool.ntp.org iburst' to : pool pool.ntp.org iburst - from: '! dumpdir /var/lib/chrony' to : dumpdir /var/lib/chrony - from: '# is unimportant.' to : | # is unimportant. # # nausch.org : allow fd00::/10 allow 10.0.0.0/24 allow 2003:a:e0d:7603::/64 allow 192.168.0.0/24 allow 2003:a:e0d:7607::/64 - from: '! local stratum 10' to : local stratum 3 - from: '! logchange 0.5' to : logchange 0.5 - from: '! mailonchange wibble@example.net 0.5' to : mailonchange django@nausch.org 0.5 - from: '! lock_all' to : lock_all
firewalld
Die Netzwerkspezifischen Definitionen für den Paketfilter holen wir uns aus den Netzwerk-Variablen unseres Hosts selbst.
$ vim inventories/production/host_vars/vml010110/kvm_vhost
- inventories/production/host_vars/vml010110/kvm_vhost
kvm_base: "kvm-arch" host_dev: "eth0" host_ip: '{{ guest_ip4_1 }}' guest_name: "vml000110" guest_zone: "idmz" guest_domain: "nausch.org" guest_desc: "Ansible-Test-VM III on new ArchLINUX" guest_mate: "true" guest_ram: 8192 guest_cpu: 4 guest_imagesize: 30 guest_imagetype: "qcow2" guest_imagemode: "compat=1.1" guest_source: "archlinux-2024.01.16-x86_64.iso" guest_zone_1: "idmz" guest_bridge_1: "br3" guest_nic_1: "eth0" guest_direction_1: "idmz_2_intra" guest_mac_1: "52:54:00:41:11:01" guest_ip4_net_1: "10.0.0.0" guest_ip4_1: "10.0.0.110" guest_mask4_1: "/24" guest_gw4_1: "10.0.0.210" guest_dns4_1: "217.237.151.142" guest_ip6_ll_1: "fe80::3:10:ff:fe00:110" guest_ip6_ls_1: "fd00::3:10:0:0:110" guest_ip6_gs_1: "2003:a:e0d:7603:10::110" guest_ip6_net_1: "2003:a:e0d:7603::" guest_mask6_1: "/64" guest_gw6_1: "fd00::3:10:0:0:210" guest_dns6_1: "2003:180:2:a000::53" guest_zone_2: "intra" guest_bridge_2: "br4" guest_nic_2: "eth1" guest_direction_2: "intra_2_idmz" guest_mac_2: "52:54:00:41:11:02" guest_ip4_net_2: "192.168.0.0" guest_ip4_2: "192.168.0.110" guest_mask4_2: "/24" guest_gw4_2: "10.0.0.210" guest_dns4_2: "217.237.151.142" guest_ip6_ll_2: "fe80::7:1921:68ff:fe00:110" guest_ip6_ls_2: "fd00::7:192:168:0:110" guest_ip6_gs_2: "2003:a:e0d:7607:1920:168:0:110" guest_ip6_net_2: "2003:a:e0d:7607::" guest_mask6_2: "/64" guest_gw6_2: guest_dns6_2:
Playbook
Die definierte Rollen chrony_client und chrony_firewalld binden wird dann z.B. in das Playbook für die Installation und Konfiguration des chrony-Daemon im Server-Mode ein.
# vim playbooks/arch_chrony_server.yml
- playbooks/arch_chrony_server.yml
--- # Ansible Playbook zum Konfigurieren des Chrony-Daemon im Server-Modus unter Arch-Linux. # Aufruf via $ ansible-playbook playbooks/arch_chrony_client.yml : # $ ansible-playbook playbooks/arch_chrony_server.yml # für einen Host aus der Hostgruppe DMZ. - name: arch_chrony_server.yml # Name des Playbooks hosts: vml010110 # Hostgruppe für die das Playbook gelten soll roles: - role: chrony_client # Chrony-Client installieren und konfigurieren tags: chrony_client # Tag-Kennzeichnung der definierten Rolle - role: chrony_firewalld # Paketfilter-Regeln für Chrony-Server anlegen tags: chrony_firewalld # Tag-Kennzeichnung der definierten Rolle ...
Playbooklauf
Die orchestrierte Variante der Installation und Konfiguration unseres chrony-Daemon im Server-Mode gestaltet sich ab sofort sehr einfach, brauchen wir doch lediglich die Konfigurationswerte im Inventory zu hinterlegen und zu pflegen und letztendlich das Playbook entsprechend aufzurufen:
$ ansible-playbook playbooks/arch_chrony_server.yml
[23:10:06] Gathering Facts ↳ vml010110 | SUCCESS | 1.79s [23:10:08] chrony_client : include_tasks ↳ vml010110 | SUCCESS | 24ms [23:10:08] ↳ chrony: Installation des chrony-Daemons. ↳ vml010110 | SUCCESS | 1.34s [23:10:10] ↳ chrony: Checken ob es bereits eine Backupdatei der chrony.conf gibt. ↳ vml010110 | SUCCESS | 679ms [23:10:10] ↳ chrony: Sofern bereits eine Backupdatei der chrony.conf existiert, diese rücksichern. ↳ vml010110 | CHANGED | 626ms [23:10:11] ↳ chrony: Backupdatei der chrony.conf Konfigurationsdatei erstellen. vml010110 | SKIPPED | 36ms [23:10:11] ↳ chrony: Änderungen an der chrony.conf mit blockinfile vornehmen. ↳ vml010110 | CHANGED | 607ms [23:10:12] ↳ chrony: Änderungen an der chrony.conf mit lineinfile vornehmen. ↳ vml010110 | CHANGED | 3.97s [23:10:16] ↳ chrony: Sicherstellen, dass der chrony Service reboot(-fest) startet. ↳ vml010110 | SUCCESS | 984ms [23:10:17] chrony_firewalld : include_tasks ↳ vml010110 | SUCCESS | 36ms [23:10:17] ↳ config: Port 123/UDP für IPv4 in der Zone IDMZ freischalten. ↳ vml010110 | CHANGED | 848ms [23:10:17] ↳ config: Port 123/UDP für IPv6 (ULA) in der Zone IDMZ freischalten. ↳ vml010110 | CHANGED | 7276ms [23:10:18] ↳ config: Port 123/UDP für IPv6 (Global-Scope) in der Zone IDMZ freischalten. ↳ vml010110 | CHANGED | 697ms [23:10:19] ↳ config: Port 123/UDP für IPv4 in der Zone INTRA freischalten. ↳ vml010110 | CHANGED | 798ms [23:10:20] ↳ config: Port 123/UDP für IPv6 (ULA) in der Zone INTRA freischalten. ↳ vml010110 | CHANGED | 774ms [23:10:20] ↳ config: Port 123/UDP für IPv6 (Global-Scope) in der Zone INTRA freischalten. ↳ vml010110 | CHANGED | 804ms [23:10:21] ↳ config: Regeländerungen auf vml000110 neu laden. ↳ vml010110 | CHANGED | 1.02s [23:10:22] system -- Play recap -- vml010110 : ok=16 changed=10 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
Links
- Zurück zu Projekte und Themenkapitel
- Zurück zu LINUX Installation und Konfiguration
- Zurück zu Zurück zur "Ansible"-Übersicht"
- Zurück zur Startseite