Skip to content

Practice Exercise 1: Syncing clock to NTP

Objective

In this exercise you will understand how to synchronize system clocks using Chrony.

Prerequisites

  • Access to Linux-based machine. Follow the steps in Lab Environment to access your machine.
  • Basic knowledge of Linux command line.

Exercises

Syncing Clock to NTP

Step 1. Connect to your machine via SSH.

Step 2. Install Chrony if it's not already installed:

sudo yum install chrony
Step 3. Start and enable the Chrony service:
sudo systemctl start chronyd
sudo systemctl enable chronyd
Step 4. Edit the Chrony configuration file
sudo nano /etc/chrony.conf
Add NTP server sources to the configuration file. For example, add the following lines to use the NTP pool servers:

server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
Step 5. Save and close the configuration file.

Step 6. Check the status of the Chrony service to verify that it's running:

chronyc tracking
This command will display information about the system's clock and how well it is synchronized with the NTP server.  

Here's a breakdown of the information provided from the above command:

Reference ID: The IP address or hostname of the NTP server to which the system is synchronized.

Stratum: The stratum level of the NTP server. Lower numbers indicate servers closer to the reference clock.

Ref time (UTC): The reference time in Coordinated Universal Time (UTC) obtained from the NTP server.

System time: The difference between the system's time and the NTP time. In this case, the system is slightly ahead of NTP time.

Last offset: The most recent offset between the system time and NTP time.

RMS offset: The root mean square (RMS) offset, which is a measure of the time offset's stability.

Frequency: The system's clock frequency offset from the reference NTP server.

Residual freq: The residual frequency offset after adjusting the clock.

Skew: The skew, or rate of change, in the system's clock frequency.

Root delay: The round-trip delay to the reference NTP server.

Root dispersion: The root dispersion, which represents the maximum error in the reference NTP server's time.

Update interval: The interval at which the system synchronizes with the NTP server.

Leap status: The leap status, which can be "Normal" or indicate a leap second adjustment.

Conclusion

Upon completing these steps, you have successfully synchronized your system with NTP servers using Chrony. This exercise helps reinforce the understanding of time synchronization.