How to set up a NTP server on CentOS 7?


In an organization, there are many administrative processes that need the registry to be correct. An essential field of the records is the date and time they are made. Therefore, it is necessary that all computers have synchronized the date and time. So, to do this it is necessary to configure an NTP server.

NTP (Network Time Protocol) is an Internet protocol for synchronizing the time and date of computer devices on a computer network. In addition, it uses port 123 of the UDP transport layer.

So, let’s set up an NTP server on CentOS 7.

1. Upgrade the system

The first step in this tutorial is to update the system. This ensures that the security patches are properly installed on your system.

Access your server and run.

:~$ su
:~# yum update
1.- Upgrade the system
1.- Upgrade the system

So, that’s it. You can continue.

2. Install NTP server

Now it is necessary to install the NTP package. It is simple as it is available in the official repositories.

:~# yum install ntp
2.- Install NTP
2.- Install NTP

Once the installation process is completed, it is necessary to edit the /etc/ntp.conf file, which is where the NTP server configuration is hosted.

First, go to the page where the official NTP servers are hosted. Here you locate the server closest to where the server is physically located.

3.- Finding the best NTP pool for the server
3.- Finding the best NTP pool for the server

Find a server in the same country and add those lines to the configuration file. As I show you in the image.

:~# nano /etc/ntp.conf
4.- Adding the NTP servers to config file
4.- Adding the NTP servers to the config file

Of course, now we have to allow network members to synchronize with the server we are configuring. In addition, it is advisable to restrict clients who cannot modify NTP server settings.

5.- Allow synchronization with the server
5.- Allow synchronization with the server

Finally, you can include a log file to find out what’s going on with the NTP server. So, it is advisable to do this because if there is a problem viewing that file you can fix it.

6.- Adding a log file for NTP
6.- Adding a log file for NTP

3. Set the Firewall rule and start the service

For the NTP server to work, it is necessary to set the standard in the Firewall so that it can have access.

:~# firewall-cmd --add-service=ntp --permanent
:~# firewall-cmd --reload
7.- Setting the Firewall rule
7.- Setting the Firewall rule

Next, enable and start the service.

:~# systemctl enable ntpd
:~# systemctl start ntpd
8.- Staring the service
8.- Staring the service

Now, let’s verify the NTP server.

4. Check the NTP server

It is now necessary to verify that everything has gone well. run this commands to check.

:~# ntpq -p
:~# date -R
9.- Checking the server status
9.- Checking the server status

In case you want to synchronize with a specific server, you can do it with the following command.

:~# ntpdate -q
10.- Using ntpd
10.- Using ntpd

And that’s it.


As you can see, setting up an NTP server is not a complicated thing. However, doing so guarantees that our computer equipment has a synchronization in time and date necessary for all processes can be performed properly.

Please share this article with your friends.


Please enter your comment!
Please enter your name here