How to install and Configure NTP client on CentOS/ RHEL/ Fedora to Synchronize the Clock
NTP, Network Time Protocol, it is an Internet protocol used to synchronize the clocks of computers or servers to some NTP server on internet or intranet. This is just a brief howto about installing and configuring NTPD (Network Time Protocol Daemon) on a Linux server which in this case is specifically NTPD. First we will install ntpd, then update the current time on the server, configure ntpd to restart on server boot, and then start ntpd.
Install the following package, for example using yum:
# yum install ntp
Update NTPD Configuration: Modify the ntpd.conf file located in the /etc/ directory.
# vi /etc/ntp.conf
Add the below to the /etc/ntp.conf file. Please be aware that there are many configuration options that can be added to /etc/ntp.conf that make it more secure and the below is a very basic configuration file.
01 # Permit time synchronization with our time source, but do not
02 # permit the source to query or modify the service on this system.
03 # restrict default kod nomodify notrap nopeer noquery
04 # restrict -6 default kod nomodify notrap nopeer noquery
05 restrict default kod nopeer notrap nomodify
06 restrict -6 default kod nopeer notrap nomodify
08 # Permit all access over the loopback interface. This could
09 # be tightened as well, but to do so would effect some of
10 # the administrative functions.
11 restrict 127.0.0.1
12 restrict -6 ::1
14 # Use public servers from the pool.ntp.org project.
15 # Please consider joining the pool (http://www.pool.ntp.org/join.html).
16 server 0.rhel.pool.ntp.org
17 server 1.rhel.pool.ntp.org
18 server 2.rhel.pool.ntp.org
20 # Undisciplined Local Clock. This is a fake driver intended for backup
21 # and when no outside source of synchronized time is available.
22 server 127.127.1.0 # local clock
23 fudge 127.127.1.0 stratum 10
25 # Drift file. Put this in a directory which the daemon can write to.
26 # No symbolic links allowed, either, since the daemon updates the file
27 # by creating a temporary in the same directory and then rename()’ing
28 # it to the file.
29 driftfile /var/lib/ntp/drift
Start & Update NTPD
On all NTP servers, run the following:
# chkconfig ntpd on
# service ntpd start
# /etc/init.d/ntpd start
Restart your ntp client using below command:
# service ntpd restart
Verify proper clock synchronization:
# ntpq -p