Tuesday 16 February 2016

How to Install and Configure NTP Server on CentOS 7

Network Time Protocol – NTP- is a networking protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks which runs over port 123 UDP at Transport Layer. In operation since before 1985, NTP is one of the oldest Internet protocols in current use. NTP was originally designed by David L. Mills of the University of Delaware, who still oversees its development.

This article describes How to Install and Configure  NTP Server on CentOS 7.

Step 1: Install and configure NTP Server:

NTP server package is provided by default in official repositories of CentOS 7 and can be installed by using yum as below command.

[root@linuxcnf ~]# yum install ntp

Step 2: Configure NTP server to Synch from NTP pool:
Now open main configuration file and comment defaults servers and add public ntp server or ISP ntp server address (as below) to synch time for local environment.

[root@linuxcnf ~]# vim /etc/ntp.conf

Server 2.in.pool.ntp.org iburst
Server 1.asia.pool.ntp.org iburst
Server 2.asia.pool.ntp.org iburst


Step 3: Configure server to allow for clients synch:

Configure server to allow clients from local networks to synchronize time with NTP server. Add the below line in NTP configuration file above ntp server ip addresses, where restrict statement controls, which networks are allowed to synchronize time with NTP server.

[root@linuxcnf ~]# vim /etc/ntp.conf
restrict mask nomodify notrap

Step 4: Configure server for separate logging:

Configure logging for NTP server, we need to add the below line in main configuration file to record additional information into a separate log file for troubleshooting or monitoring.

[root@linuxcnf ~]# vim /etc/ntp.conf
logfile /var/log/ntp.log

Step 5: Configure firewalld rules for NTP server:

NTP service use UDP port no. 123. Need to enable port 123 to time synchronization for clients with NTP server.

[root@linuxcnf ~]# firewall-cmd –-permanent –add-service=ntp
[root@linuxcnf ~]# firewall-cmd --reload

Step 6: Start NTP Service:
Now configuration done and we need to start ntp service as executing the below commands.

[root@linuxcnf ~]# service ntpd restart
[root@linuxcnf ~]# chkconfig ntpd on

Step 7: Verify Server Time Synch:
To verify the server time synchronization from given pool server. May be it will take some time to synchronize from the pool server. So wait for few minutes and check with the below commands and it should show as look like the below snap:

[root@linuxcnf ~]# ntpq –p
[root@linuxcnf ~]# ntpstat


NTP Server Configuration Done….

No comments:

Post a Comment