NTP Server Install and Configuration in CentOS 5 & 6

NTP Server Install and Configuration

Network Time Protocol is used to synchronize the time on your Linux system with a centralized NTP server.

A local NTP server on the network can be synchronized with an external timing source to keep all the servers in your organization in-sync with an accurate time.

Step 1: PreWork

Before install NTP server, check is the package is installed or not already by using rpm commend

[root@CentOS66x64 ~]# rpm -qa ntp

ntp-4.2.6p5-1.el6.centos.x86_64 à if you notice package is listing, skip step 2.

[root@CentOS66x64 ~]#

Step 2: NTP Installation
[root@foxutech ~]# yum install ntp
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: centos.excellmedia.net
* extras: centos.excellmedia.net
* updates: centos.excellmedia.net
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package ntp.i386 0:4.2.2p1-18.el5.centos set to be updated
–> Finished Dependency Resolution

Dependencies Resolved

Package                           Arch                               Version                                               Repository                             Size
ntp                               i386                               4.2.2p1-18.el5.centos                                 updates                               1.3 M

Transaction Summary
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 1.3 M
Is this ok [y/N]: t
Is this ok [y/N]: y
Downloading Packages:
ntp-4.2.2p1-18.el5.centos.i386.rpm                                                                                                               | 1.3 MB     00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing     : ntp                                                                                                                                              1/1

ntp.i386 0:4.2.2p1-18.el5.centos


Step 3: NTP Configuration
[root@foxutech ~]# vi /etc/ntp
ntp/      ntp.conf
[root@foxutech ~]# vi /etc/ntp.conf
[root@foxutech ~]# vi /etc/ntp.conf
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod 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 -6 ::1

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

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org
server 3.centos.pool.ntp.org

#broadcast key 42         # broadcast server
#broadcastclient                        # broadcast client
#broadcast key 42             # multicast server
#multicastclient              # multicast client
#manycastserver         # manycast server
#manycastclient key 42  # manycast client

# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server     # local clock
fudge stratum 10

# Drift file.  Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()’ing
# it to the file.
driftfile /var/lib/ntp/drift

# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys

Step 4: Start and Check NTP
[root@foxutech ~]# chkconfig ntpd on
[root@foxutech ~]# /etc/init.d/ntpd start
Starting ntpd:                                             [  OK  ]
For checking :
[root@foxutech ~]# ntpq -p
[root@foxutech ~]# ntpdc -c sysinfo
[root@foxutech ~]# ntpdate –u
[root@foxutech ~]# date
Thu Jul 30 11:26:30 IST 2015