Setup Chrony NTP Server Debian 10 / CentOS 8

Self-Hosting Apr 5, 2021

Following on from our last post about a Local NTP server where Chrony was implemented with a Docker container, in this guide we will be installing Chrony onto Debian or CentOS without using Docker.

What is Chrony?

Chrony is a lightweight NTP server that has been designed for unstable environments such as a Virtual Machine or Docker container.

It's a replacement for NTPD, it aims to be lightweight while being less susceptible to attacks.

Chrony Official Site

Installation

  1. Install Chrony
    Debian: sudo apt install chrony
    CentOS: sudo yum -y install chrony

  2. Check that Chrony is running.
    sudo systemctl status chronyd

  3. Enable Chrony daemon upon boot.
    sudo systemctl enable chronyd

  4. Edit the config
    Debian:sudo nano /etc/chrony/chrony.conf
    CentOS:sudo nano /etc/chrony.conf

Example Config

Upstream pool use: pool <POOL-URL>
Upstream server use: server <SERVER-URL/IP>

Ideally, you should have about 5 servers listed.

Lists of Public NTP Servers

https://www.advtimesync.com/docs/manual/stratum1.html
https://gist.github.com/mutin-sa/eea1c396b1e610a2da1e5550d94b0453

To speed up the startup process place iburst after your prefered server/pool.

  1. Restart Chrony
    sudo systemctl restart chronyd

  2. Lets check it's working.
    On a different Linux machine run ntpdata -q <SERVER-URL/IP>

  3. You may need to open port 123 on your firewall ;)
    e.g sudo ufw allow 123/udp

Please consider adding your server to the NTP Pool Project.

Handy Chrony Commands

  1. sudo chronyc serverstats
NTP packets received       : 53583
NTP packets dropped        : 0
Command packets received   : 2
Command packets dropped    : 0
Client log records dropped : 26571
  1. sudo chronyc tracking
Reference ID    : ABC123DEF (ntp.example.com)
Stratum         : 3
Ref time (UTC)  : Wed Mar 24 23:00:42 2021
System time     : 0.000102126 seconds fast of NTP time
Last offset     : +0.000205232 seconds
RMS offset      : 0.000515604 seconds
Frequency       : 26.737 ppm slow
Residual freq   : +0.028 ppm
Skew            : 1.925 ppm
Root delay      : 0.013609397 seconds
Root dispersion : 0.000514330 seconds
Update interval : 64.6 seconds
Leap status     : Normal
  1. sudo chronyc sources
210 Number of sources = 3
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
#* GPS0                          0   4   377    11   -479ns[ -621ns] +/-  134ns
^? foo.example.net               2   6   377    23   -923us[ -924us] +/-   43ms
^+ bar.example.net               1   6   377    21  -2629us[-2619us] +/-   86ms

Tags