DEV Community

Randika Madhushan Perera
Randika Madhushan Perera

Posted on

Set NTP

1. Introduction to NTP

The Network Time Protocol (NTP) allows for the precise distribution of time and date information to keep networked computer systems' time clocks synced to a common reference over the network or the Internet. Many standards organizations across the world have atomic clocks that can be used as a reference.

In IT, accurate timekeeping is critical for a variety of reasons. Accurate time stamps in packets and logs, for example, are necessary for networking. Because logs are used to analyze service and security issues, time stamps generated on separate systems must be generated by synchronized clocks to be of genuine use.

In Linux systems, NTP is implemented by a daemon running in user space.

2. NTP Setup

Question: Configure your system as an NTP client of "classroom.example.com"

Step 01

Check the status of chronyd.service.

[root@servera ~]$ systemctl status chronyd.service
Enter fullscreen mode Exit fullscreen mode

Step 02

Edit the /etc/chrony.conf file and add the below line.

When you add classroom.example.com into the chrony.conf file, get a copy of the line as per the screenshot, and paste it after the pool 2.rhel.pool.ntp.org iburst like below (Highlighted line) and save it.

ntp file configs

Step 03:

Now we need to restart the chronyd.service and check the status if it is running.

[root@servera ~]$ systemctl restart chronyd.service

[root@servera ~]$ systemctl status chronyd.service
● chronyd.service - NTP client/server
 Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor
 preset: enabled)
 Active: active (running)
Enter fullscreen mode Exit fullscreen mode

Step 04:

Now we want to verify the change. In order to do that run the below command.

[root@servera ~]$ chronyc sources -v After running this command you will see the below output. If you get like below your NTP setup is successes.

[student@servera ~]$ chronyc sources -v
210 Number of sources = 4

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| /   '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* time.cloudflare.com           3   9   377   467  +3057us[+3544us] +/-   97ms
^+ time.cloudflare.com           3   9   377    10  +2709us[+2709us] +/-   88ms
^? time.cloudflare.com           0   6     0     -     +0ns[   +0ns] +/-    0ns
^? time.cloudflare.com           0   6     0     -     +0ns[   +0ns] +/-    0ns
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
lasanthasilva profile image
Lasantha Sanjeewa Silva

AweSome