Configure NTP on CentOS
NTP (Network Time Protocol) is a networking protocol for clock synchronization between computer using a another reference time source.
Installation
NTP contains all the utilities that will synchronize the clock of all your computer, the package is bult-in by default on CentOS repositories, so you only have to run the following command:
# yum install ntp
Enable on
# chkconfig ntpd on
Configure a NTP client
Open the/etc/ntp.conf file and edit the following line:
server ntp.server.com
The ntp.server.com must be replace with the hostname or IP address of the server you are going to use to synchronize. for example if your server is 192.168.10.9 , enter server 192.168.10.9.
You can also use public server like: www.pool.ntp.org
If you use a public server edit the main configuration file by comment the default list of Public Servers from pool.ntp.org project and replace it with the list provided for your country.
Allow only specific clients
To only allow machines on your own network to synchronize with your server, add the following restrict line to your /etc/ntp.conf file
restrict 192.168.10.0 mask 255.255.255.0 nomodify notrap
The nomodify notrap statements suggest that your clients are not allowed to configure the server or be used as peers for time sync.
Replace 192.168.10.0 and mask with actual remote ISP or pool.ntp.org server IP. Save and close the file.
Enable log file
Just in case you need information for troubleshooting to solve problems with your service add a log file statement which will record all server issues, open for editing the /etc/ntp.conf file and add the following line
logfile /var/log/ntp.log
Save and close the file. Finally, start ntpd:
# service ntpd start
