Sunday, September 25, 2022

Install and Configure NTP Server and Client on Centos 7

In this article, we want to teach you to Install and Configure NTP Server and Client on Centos 7.

Network Time Protocol (NTP) is an internet protocol used to synchronize with computer clock time sources in a network. It belongs to and is one of the oldest parts of the TCP/IP suite. The term NTP applies to both the protocol and the client-server programs that run on computers.

Install and Configure NTP Server and Client on Centos 7

Before you start to set up NTP on your server, you need to log in to your server as a non-root user with sudo privileges. To do this, you can follow our article the Initial Server Setup with Centos 7.

Now follow the steps below to complete this guide.

Set up NTP Server on Centos 7

First, you need to update your local package index with the following command:

sudo yum update -y

Then, you can install NTP packages on Centos 7 with the following command:

sudo yum install ntp -y

At this point, you need to configure the NTP server. To add NTP Server information in /etc/ntp.conf, you need to open the file with your favorite text editor, here we use vi:

sudo vi /etc/ntp.conf

You need to provide the NTP Server IP or hostname with the server keyword. You can also add the Server information at the end of the file.

# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).

driftfile /var/lib/ntp/drift

# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default nomodify notrap nopeer noquery

# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict ::1

# Hosts on local network are less restricted.
#restrict mask nomodify notrap

# Use public servers from the project.
# Please consider joining the pool (
server iburst
server iburst
server iburst
server iburst

When you are done, save and close the file.

If you want to restrict the NTP Server access for some of the clients, you can edit the /etc/ntp.conf file and replace the network information with the client network and their subnet mask information. This will restrict the given Client access.

restrict mask nomodify notrap

Now restart your NTP service on Centos 7 with the command below:

sudo systemctl restart ntpd

Enable your NTP server to start on boot on Centos 7:

sudo systemctl enable ntpd

Next, you can check your NTP Synchronization Status with the following command:

ntpq -np
remote           refid           st t when poll reach delay   offset jitter
* 2 u 3 64 1 4.126 -1.069 2.578 3 u 2 64 1 0.327 -0.593 0.092
2a00:ff0::19 2 u 1 64 1 49.357 -0.264 1.640 2 u 2 64 1 5.637 -1.318 0.178

If everything went well then Your date and time should be synchronized from the NTP Server on Centos 7. You can verify your timezone with the following command:

Local time: Sat 2022-04-16 03:36:54 EDT
Universal time: Sat 2022-04-16 07:36:54 UTC
RTC time: Sat 2022-04-16 07:36:53
Time zone: America/New_York (EDT, -0400)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: yes
Last DST change: DST began at
Sun 2022-03-13 01:59:59 EST
Sun 2022-03-13 03:00:00 EDT
Next DST change: DST ends (the clock jumps one hour backwards) at
Sun 2022-11-06 01:59:59 EDT
Sun 2022-11-06 01:00:00 EST

If you want to query from NTP Server and check the current offset and delay, you can use the command below. For example:

ntpdate -q
server, stratum 3, offset -0.001746, delay 0.02603
server, stratum 2, offset -0.002588, delay 0.03148
server, stratum 2, offset -0.001501, delay 0.02661
server, stratum 3, offset -0.001788, delay 0.02602
16 Apr 03:37:34 ntpdate[30123]: adjust time server offset -0.001501 sec

Install and Configure NTP CLient

At this point, you can install the NTP on your Client’s machine. Here our client machine is Centos.

Install your NTP client with the command below:

sudo yum install ntp

Then, configure your ntp.conf file and point to your NTP server:

sudo vi /etc/ntp.conf
server your-server-ip-address

When you are done, save and close the file.

Next, restart your NTP client:

sudo service ntpd restart

Test your NTP client status whether properly configured or not by running the below command:

ntpq -p

For more information, you can visit the NTP Documentation page.


At this point, you learn to Install and Configure NTP Server and Client on Centos 7.

Hope you enjoy it.

Related Articles


Please enter your comment!
Please enter your name here

Latest Articles


Most Popular