How to install and configure Chrony NTP on Linux

Home > Search > How-to
  by

If our Linux is a VM running on VMWare's vSphere, ensure that the VM is not using vSphere for time synchronization.

  • Launch VSphere Client
  • Right-click on the VM, and select open console.  The VM console window will appear.
  • In the top menu of the VM console window, click VM and select Edit Settings.  The Virtual Machine Properties pop-up box appears.
  • In the Virtual Machine Properties pop-up box, click the Options Tab.
  • In the Options Tab, highlight VMware Tools in the left panel, and ensure that Synchronize guest time with host in the right panel is not check-marked.  Click OK to close the Virtual Machine Properties pop-up box.

Use the yum install or apt-get install command to install Chrony NTP client/server on Linux.

apt-get install chrony
yum install chrony

Depending on the Linux distro you are using, the configuration file for chrony is located at /etc/chrony.conf or /etc/chrony/chrony.conf. Our Linux machine can be configured to only be an NTP client, which means that we will use NTP to sychronize time.  Our Linux machine can also be configured as both an NTP client and an NTP server. When configured as an NTP server, other computers can make connections to our computer to synchronize time. If we do not make any changes to the chrony configuration file, our machine will be an NTP client only. At the very beginning of the chrony.conf file are a few NTP servers.

  • server 0.fedora.pool.ntp.org iburst
  • server 1.fedora.pool.ntp.org iburst
  • server 2.fedora.pool.ntp.org iburst
  • server 3.fedora.pool.ntp.org iburst

These are the 4 NTP servers chrony utilizes by default to synchronize time. It is entirely possible to use different NTP servers, such as time.apple.com.  If you will be using a different NTP server as the preferred NTP server, list the preferred NTP server before the 4 default NTP servers. We want to also add pool.ntp.org as the last NTP server. We list pool.ntp.org last because it is the least desireable NTP server, but the most likely NTP server to be available.

  1. In Terminal, enter nano /etc/chrony.conf or /etc/chrony/chrony.conf.
  2. Below the 4 default NTP servers, add server pool.ntp.org iburst
  3. Press Ctrl O and then Enter to save the changes
  4. Press Ctrl X to exit the nano editor

The /etc/chrony.conf file will also have the allow option commented out. As an example, if you were part of a 192.168.x.x network, the /etc/chrony.conf file would contain the following listing.

  • #allow 192.168/16

By having this option commented out, our Linux machine will only be an NTP client.  If we were to uncomment this line, this would start the process of our Linux machine being an NTP server.

Because we have made changes to the chrony configuration file, we need to restart the chrony daemon.  Depending on your Linux distro, one of the two following commands will restart the chrony daemon.

systemctl restart chronyd
service chrony restart

We can then verify that the chrony daemon is running.  Again, depending on your Linux distro, one of the following two commands will show the status of the chrony daemon.

systemctl status chronyd
service chrony status

 

We can also use the chronyc sources command to verify that chrony is using our preferred and backup NTP servers. In this example, I have only one NTP server listed in my chrony configuration file, thus the chronyc sources command shows the one NTP server.

 

We can also use the chronyc tracking command to verify that we are synchronized.  If leap status is normal, we are synchronized. On the other hand, if leap status is not synchronized, we are not synchronized.

 

Lastly, we can issue the date command to display the current date and time, and compare the date and time listed to a world clock to know if we are synchronized.



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments