How to Install and Configure an NTP Client and Server on Linux

This article will help to know how to configure an NTP (Network Time Protocol) server and client on RHEL/Cent OS Linux to manage the system clock with to help of an NTP server.

NTP (Network Time Protocol)

NPT is used to synchronize a computer’s machine’s time with another time source. In RHEL / CentOS  Linux we can use NTP or OpenNTPD server, which provides client and server software for time synchronization.

Installing NTP Software

The NTP package have utilities and daemons that will synchronize the machine time to Coordinated Universal Time (UTC) via the NTP protocol. The NTP package has ntpdate (Which updates the date and time from the remote machines using the network) and ntpd (A daemon which adjusts the system time).

# yum install ntp -y
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base:
 * epel:
 * extras:
 * updates:
Resolving Dependencies
--> Running transaction check
---> Package ntp.x86_64 0:4.2.6p5-5.el6.ntosce will be updated
---> Package ntp.x86_64 0:4.2.6p5-5.el6.centos.4 will be an update
--> Processing Dependency: ntpdate = 4.2.6p5-5.el6.centos.4 for package: ntp-4.2.6p5-5.el6.c            entos.4.x86_64
--> Running transaction check
---> Package ntpdate.x86_64 0:4.2.6p5-5.el6.centos will be updated
---> Package ntpdate.x86_64 0:4.2.6p5-5.el6.centos.4 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
 Package          Arch            Version                            Repository        Size
 ntp              x86_64          4.2.6p5-5.el6.centos.4             updates          595 k
Updating for dependencies:
 ntpdate          x86_64          4.2.6p5-5.el6.centos.4             updates           77 k
Transaction Summary
Upgrade       2 Package(s)
Total download size: 672 k
Downloading Packages:
(1/2): ntp-4.2.6p5-5.el6.centos.4.x86_64.rpm                         | 595 kB     00:00
(2/2): ntpdate-4.2.6p5-5.el6.centos.4.x86_64.rpm                     |  77 kB     00:00
Total                                                       261 kB/s | 672 kB     00:02
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : ntpdate-4.2.6p5-5.el6.centos.4.x86_64                                                1/4
  Updating   : ntp-4.2.6p5-5.el6.centos.4.x86_64                                                    2/4
  Cleanup    : ntp-4.2.6p5-5.el6.centos.x86_64                                                      3/4
  Cleanup    : ntpdate-4.2.6p5-5.el6.centos.x86_64                                                  4/4
  Verifying  : ntp-4.2.6p5-5.el6.centos.4.x86_64                                                    1/4
  Verifying  : ntpdate-4.2.6p5-5.el6.centos.4.x86_64                                                2/4
  Verifying  : ntpdate-4.2.6p5-5.el6.centos.x86_64                                                  3/4
  Verifying  : ntp-4.2.6p5-5.el6.centos.x86_64                                                      4/4
  ntp.x86_64 0:4.2.6p5-5.el6.centos.4
Dependency Updated:
  ntpdate.x86_64 0:4.2.6p5-5.el6.centos.4

Configuration  NTP Server

If we have lots of server and desktop machines in the environment and then we should have the NTP server so that all the servers can contact and update the NTP server provided by the ISP or the Public time located at The server then allows the other machines in our network to request the time date.

Demo Environment Details        Local NTPD server           ISP NTP server       NTP clients network

Open the configuration file and add the following lines –

restrict default ignore

The Above will deny all the access to any machine, server or clients. We needed to add the specific  authorization policy to settings

restrict  mask nomodify notrap noquery

Configure NTP Client to Access the Local

NTP server Now  we needed to allow NTP clients to access the Server, to  our network, we allow network to synchronize the time over network located in the own environment
Open /etc/ntp.conf file and all the bellow lines so that it looks the local NTP server.
# Hosts on local network are less restricted.
restrict mask nomodify notrap

Save the config file and restart the NTP services

# service ntpd start

Configure NTP Client with our Local Server

Open /etc/ntp.conf and edit the file

# vi /etc/ntp.conf

And make sure the following line exists

# Server

Where is the hostname/IP address of the site. If your NTP server is located at enter server if we have a public NTP server then provide the server IP address.

Configure the Corn to Update the Server

Run the below command to update the ntpd file in cron’s and it will instructs crond to run the ntpd and set the clock and exis and -u use the user name ntp to do the clock changes.

# echo ’30 * * * * root /usr/sbin/ntpd -q -u ntp:ntp’ > /etc/cron.d/ntpd

After the successful configuration using the above steps we can configure a standalone an NTP client and also configure an NTP server in the local environment to an NTP server to all the local client and server.