blog posts

How to Install NTP Server and Client on Ubuntu

How to install NTP server in Linux Ubuntu

An NTP server is a network time protocol. NTP is responsible for synchronizing system time and date to prevent communication problems in a large global network.

You may have encountered a message with the content “Update your system time and time zone” when running the program or opening a site. This process happens when your system displays an incorrect date and time.

In large Windows networks, the PDC Emulator service is responsible for synchronizing the system time, and in Linux systems, a server is usually selected as the NTP server.

The NTP server receives timely information from trusted Internet NTP servers and forwards them to systems within the network.

In this article from the Linux training series, we will learn about installing the NTP server on CentOS Linux. To buy a Linux virtual server, you can visit the website and find the right plan.

Buying a Linux virtual server

How to install NTP server on Linux CentOS 8 CentOS 7

This tutorial will explore how to set up an NTP server on Linux CentOS with Linux commands and how to run an NTP server. Please stay with us for the rest of this tutorial.

How the NTP protocol works

NTP provides a time signal from atomic clocks to the server and distributes it in the system with the help of UTC universal time.

An NTP server consists of synchronization devices such as a client that receives UTC and provides it to clients.

Clients and servers communicate in a series of requests and responses as follows:

  • The client sends a request package or NTP Request Packet to the time server and confirms the execution time (start time of the resource).
  • The server confirms the time of receiving the request package.
  • The server sends a response package to the client again.
  • When the client receives the response packet, it confirms the destination time.

This process may take only a few nanoseconds.

Timestamp allows the client to calculate field latency, check the difference between its internal time and the time provided by the server, and reset the clock accurately if necessary.

In the rest of this article, we will learn how to install it on CentOS Linux.

Installing an NTP server on CentOS Linux

1- First, connect to your CentOS Linux console.

2- Install the NTP service package with the yum command

yum install NTP

3- After installation, open the NTP settings file with an editor:

nano /etc/NTP.conf

Note: In this file, you will see the settings for your NTP server. Look for terms that start with “server” and then replace them with the # sign.

You can get help from to choose a better and closer server. First, log in and select your geographic region to display the names of servers near you. It is suggested to add 2 or 3 servers to this file.

4- Next, enter the following command in the NTP.conf file so that the service license is sent to your network IPs:

restrict netmask nomodify notrap

Note: The above command allows access to Make sure to enter your network IP address instead of the network’s IP address. And after making changes in the NTP.conf file, save it.

5- If you need to view troubleshooting or service operations, create a log file and add the following statement to the NTP.conf file:

logfile /var/log/ntp.log

6- At the end, after executing the above commands, the image of your NTP.conf file will be as follows:

7- When you have made all the changes, restart your service:

Service ntpd restart

8- Enter the following command to test the accuracy of the NTP service:


date -R

The first command checks the connectivity of the added servers.

The second command displays the complete system update date.

If you get the correct result from the above commands, setting up the NTP server in CentOS Linux is done successfully.

Note that the NTP protocol works on port 123 with the UDP protocol, so make appropriate changes to your Linux firewall to open this port.


Network Time Protocol is a protocol that works with UDP port 123 in the transport layer. This protocol allows computers on a network to synchronize time.

Over time, the computer’s internal clock ignores the time issue.

Especially with client and server log files or if you want to replicate servers or databases. In this article, we tried to show you how to install an NTP server on CentOS Linux.

You can also install the NTP server on Ubuntu, Debian, and Windows Server. Good luck!