Customise Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorised as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.

No cookies to display.

Setting Up NTP server on CentOS 7

What is NTP

NTP (Network Time Protocol) is a protocol used to synchronize computer times over a network, and it is one of the oldest TCP/IP protocol stack parts which is highly fault-tolerant and scalable. There are thousands of NTP servers around the world with access to highly precise atomic clocks and GPS clocks, NTP uses Coordinated Universal Time (UTC) to synchronize computer clock times with precision.

Install NTP Server

First, install NTP package on your system using “yum” with the command below:

yum install ntp

Set restrict values in the configuration file

Open the NTP configuration file with your preferred text editor, we are going to use “vi”:

vi /etc/ntp.conf

make sure that the following two lines are uncommented:


restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery

The restrict line allow clients to query your time server, let’s see the configured parameters:

noquery prevents dumping status data from ntpd.

notrap prevents control message trap the service.

nomodify discards all ntpq queries that attempt to modify the server.

nopeer prevents all packets that attempt to establish a peer association.

kod (kiss-to-death) packet is to be sent to reduce unwanted queries.

Allow only specific clients

To only allow machines from your network to synchronize with your NTP server, you can add the following line to your configuration file:

vi /etc/ntp.conf
restrict 10.0.0.10 mask 255.255.255.0 nomodify notrap

If the localhost should have full access to every query and modify, set the line below:

restrict 127.0.0.1

Add local clock as a backup

Add the local clock to the “ntp.conf” file so that if the NTP server is disconnected from the internet, it can provide time from its local system clock.


server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10

Setup NTP log and Driftfile

declare the log and driffile location in your “ntp.conf” file:

vi /etc/ntp.conf

Add the following lines, you can change location and file values as you preferred:


driftfile /var/log/ntp/ntp.drift
logfile /var/log/ntp/ntp.log

The driftfile is used to log how far your clock is from what it should be, and slowly NTP should lower this value as time progress.

Start and Enable NTP server

After setting the preferred configuration parameters in the configuration file you can start and enable NTP service with the following two commands:

systemctl restart ntpd
systemctl enable ntpd

Leave a Reply

Your email address will not be published. Required fields are marked *