Setting Up NTP (Network Time Protocol) Server in RHEL/CentOS 7

Step 1: Install ntp server package

#yum install ntp -y

Step 2: Get official NTP servers located near to your location. I am using Asia servers for this setup

server 0.asia.pool.ntp.org
server 1.asia.pool.ntp.org
server 2.asia.pool.ntp.org
server 3.asia.pool.ntp.org

Step 3: Open /etc/ntp.conf file

Add the servers replacing existing lines

server 0.asia.pool.ntp.org iburst
server 1.asia.pool.ntp.org iburst
server 2.asia.pool.ntp.org iburst
server 3.asia.pool.ntp.org iburst

Step 4: Allow your network for NTP sync in /etc/ntp.conf

restrict 192.168.0.0 mask 255.255.0.0 nomodify notrap

Step 5: Add log file entry in /etc/ntp.conf for troubleshooting purposes

logfile /var/log/ntp.log

Step 6: Save the file

Step 7: Add firewall rules for NTP service

# firewall-cmd –permanent –add-service=ntp
# firewall-cmd –reload

Step 8: Enable and Start NTP Service

# systemctl start ntpd
# systemctl enable ntpd
# systemctl status ntpd

[root@mail ~]# systemctl status ntpd
â ntpd.service – Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2016-08-22 21:35:11 PHT; 1h 2min ago
Process: 11184 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 11185 (ntpd)
CGroup: /system.slice/ntpd.service
ââ11185 /usr/sbin/ntpd -u ntp:ntp -g

Aug 22 21:35:11 mail.marskarthik.com systemd[1]: Starting Network Time Service…
Aug 22 21:35:11 mail.marskarthik.com systemd[1]: Started Network Time Service.
Aug 22 21:35:11 mail.marskarthik.com ntpd[11185]: proto: precision = 0.062 usec
Aug 22 21:35:11 mail.marskarthik.com ntpd[11185]: 0.0.0.0 c01d 0d kern kernel time syn…ed
Hint: Some lines were ellipsized, use -l to show in full.

Step 9: Run the following commands to verify NTP peers synchronization status and your system time

# ntpq -p
# date -R

[root@mail ~]# ntpq -p
remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
-mail.funix.net  128.199.84.169   3 u   77  128  377  218.562   96.769   5.066
*103-18-128-60.i 140.112.2.189    2 u   95  128  377   50.891   43.689   4.470
+send.mx.cdnetwo 204.123.2.5      2 u   98  128  357  126.984   52.270  10.885
+x.ns.gin.ntt.ne 249.224.99.213   2 u   90  128  377   57.621   38.352   4.129
[root@mail ~]# date -R
Mon, 22 Aug 2016 22:41:38 +0800
[root@mail ~]#

Step 10: Use this server ip address as your NTP server for your internal network devices/computers.

This entry was posted in CentOS, Linux, RHEL. Bookmark the permalink.

Leave a Reply

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