Install an NTP Server with Chrony on Ubuntu 20.04

Updated on November 21, 2023
Install an NTP Server with Chrony on Ubuntu 20.04 header image

Introduction

Chrony is a Network Time Protocol (NTP) client. An NTP server allows all devices on a network to synchronize their time. This article explains how to install and configure Chrony on Ubuntu 20.04.

Prerequisites

Install and Configure Chrony

  1. List the available time zones and choose your preference.

     $ sudo timedatectl list-timezones
  2. Set the server time zone. For example, change Africa/Nairobi to your time zone.

     $ sudo timedatectl set-timezone Africa/Nairobi
  3. Update the system packages.

     $ sudo apt update
  4. Install Chrony.

     $ sudo apt install chrony -y
  5. Start the Chrony service.

     $ sudo systemctl start chronyd
  6. Check the status of the service.

     $ sudo systemctl status chronyd
  7. Check the number of connected servers and peers.

     $ chronyc activity
  8. Show the statistics for each server.

     $ chronyc sourcestats -v
  9. Edit the Chrony configuration file.

     $ sudo nano /etc/chrony/chrony.conf
  10. Add the following code to the end of the file. Change 192.168.2.12 to your server's IP address. You can add other servers by specifying their IP addresses.

    server 192.168.2.12

  11. Save and exit the file.

  12. Synchronize the servers.

     $ sudo timedatectl set-ntp true
  13. Restart the Chrony service.

     $ sudo systemctl restart chronyd
  14. Check the list of clients added.

     $ sudo chronyc clients
  15. Check the Chrony sources.

     $ chronyc sources
  16. Check the server chrony is tracking with its performance metrics.

     $ chronyc tracking

More Information

See the chrony FAQ for more information.