Geavanceerd
Zoeken inInstallatiegidsen
Zo zoek je
  • Plak een foutmelding tussen aanhalingstekens, bijv. "permission denied", om de oplossingstabel te vinden.
  • Kies een gebied en een deel van de gids (installeren, eerste instellingen, dagelijks gebruik, beveiliging, oplossingen) om direct naar de juiste stap te gaan.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

Gids 77chrony (NTP) · System

Install and set up chrony (time sync, NTP)

Correct time is invisible until it breaks: TLS certificates fail, Kerberos and AD logins stop, logs from different servers can not be compared, databases and clusters (etcd, Kafka) get confused, and DNSSEC validation fails. chrony keeps the clock right with NTP servers — fast and precise, even on VMs and laptops. This guide installs and configures chrony as a client and as a time server for your network, adds NTS (secure NTP), and covers the checks every admin should know.

  • 10 Lessen
  • 5 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

77.1

Know it before you install

chronyd asks several time sources (NTP servers or pools), picks the best, and slowly adjusts the clock (or steps it once when it is far off). A server can also serve time to your network (allow). The real-time clock (RTC) is kept in sync too.

ItemRHEL / Rocky / AlmaUbuntu / Debian
Packagechrony (installed by default)chrony (Ubuntu 24.04 uses systemd-timesyncd by default)
Servicechronyd.servicechrony.service
Config/etc/chrony.conf/etc/chrony/chrony.conf (+ /etc/chrony/sources.d/)
Toolchronycchronyc
Port123/udp (only needed to serve time; clients use outgoing UDP 123)the same

77.2

Install on RHEL, Rocky, Alma and Fedora

dnf -y install chrony
systemctl enable --now chronyd
chronyc tracking

77.3

Install on Ubuntu and Debian

Installing chrony replaces systemd-timesyncd (only one time service may run):

apt-get update
apt-get install -y chrony
systemctl enable --now chrony
timedatectl

77.4

First configuration: a good client

Use 3–4 sources (or a pool), step the clock at start if needed, and keep the RTC in sync:

/etc/chrony.conf
pool 2.rhel.pool.ntp.org iburst maxsources 4
server time.cloudflare.com iburst nts
server ntp1.corp.example.com iburst prefer
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
keyfile /etc/chrony.keys
ntsdumpdir /var/lib/chrony
leapsectz right/UTC
logdir /var/log/chrony
SettingWhy
pool … iburstSeveral servers from a pool; iburst = fast first sync.
server … ntsNTS (Network Time Security): the answers are authenticated, not forgeable.
preferUse your company time server first when it is good.
makestep 1.0 3In the first 3 updates, jump the clock if it is more than 1 s off (after that, adjust slowly).
rtcsyncKeep the hardware clock right too.

In the cloud, use the provider's time service: AWS 169.254.169.123 (server 169.254.169.123 prefer iburst), Google metadata.google.internal, Azure uses a host time source (PTP) — follow the cloud docs.

systemctl restart chronyd
chronyc sources -v
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* time.cloudflare.com           3   6   377    32   -142us[ -171us] +/-   12ms
^+ ntp1.corp.example.com         2   6   377    31   +310us[ +281us] +/-   20ms
chronyc tracking
System time     : 0.000041 seconds fast of NTP time
Leap status     : Normal

^* = the source in use, ^+ = good backup, Reach 377 = the last 8 queries all answered.

77.5

Serve time to your network

On 2–3 internal time servers, allow your networks to ask them:

/etc/chrony.conf (add on the time servers)
allow 10.0.0.0/8
allow 192.168.0.0/16
local stratum 10
firewall-cmd --permanent --add-service=ntp
firewall-cmd --reload
systemctl restart chronyd
chronyc clients

local stratum 10 lets the server keep serving time if it loses its upstream sources for a while (clients see it is less trusted).

77.6

Daily use: the commands and the real uses

chronyc tracking
chronyc sources -v
chronyc sourcestats
chronyc activity
chronyc makestep
timedatectl
timedatectl set-timezone Asia/Riyadh
timedatectl show -p NTPSynchronized

Real uses at work:

  • Every server: correct time for logs, TLS, Kerberos/AD, clusters and backups.
  • Internal time servers for networks without internet.
  • Monitoring: alert when a server's offset is too big (Node Exporter node_timex_* metrics).

77.7

Make it safe

Security checklist:

  • Several sources (at least 3) so one bad server can not move your clock; NTS where possible.
  • allow only on real time servers, only for your networks; no open NTP server on the internet.
  • One time service per host (chrony or timesyncd).
  • Servers in UTC is simplest; set the user-facing time zone in apps.
  • Watch chronyc tracking offset in monitoring.

77.8

Update and remove

dnf -y upgrade chrony
apt-get install --only-upgrade -y chrony

Do not remove time sync from servers. To switch back to systemd-timesyncd on Ubuntu: apt-get purge chrony && apt-get install systemd-timesyncd.

Commando's in deze les

77.9

Fix common problems

ProblemCauseFix
chronyc sources shows ^? and Reach 0UDP 123 out is blocked, or DNS fails.Open outgoing UDP 123; use IPs of internal servers; check DNS.
Clock far off and not correctedmakestep only works at the start.chronyc makestep once; check that makestep is in the config.
506 Cannot talk to daemonchronyd is not running.systemctl start chronyd.
Two time services fightsystemd-timesyncd and chrony both active.Keep one: systemctl disable --now systemd-timesyncd.
Clients can not sync from your serverNo allow line or firewall.Add allow NET; open the ntp service; chronyc clients.
TLS errors "certificate not yet valid"Wrong time on the client.Fix time sync first, then retry.

77.10

Next steps

1What do ^* and Reach 377 mean in chronyc sources?

^* is the source in use; 377 means the last 8 queries all got an answer.

2What does makestep 1.0 3 do?

In the first 3 updates, chrony jumps the clock when it is more than 1 second off.

Alle commando's in dit hoofdstuk