Computers, like any digital device, have clocks in them. Aside from telling users the time, they also provide a sequencing mechanism for internal core functions and digital circuitry. However, sometimes these clocks malfunction. It might be because of a bad CMOS battery or a timezone mix-up. Fortunately, CentOS, or any Linux box for that matter, have a tool that synchronizes its clocks with central servers.
The Network Time Protocol (NTP) is such a tool. It functions as an initial configuration setter and auto updater for Linux or CentOS boxes.
If ntp is not installed in your CentOS box, here’s how to do it with yum:
#yum install ntp
As opposed to Windows boxes that require special applications to configure, Linux daemons and services can be modified with a basic text editor. Stored in the /etc/ directory, these configuration files can be easily changed to suite your needs. The Network Time Protocol daemon is no different. Here’s how to configure it:
For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
# 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 192.168.1.0 mask 255.255.255.0 nomodify notrap
# 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 iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
#broadcast 192.168.1.255 autokey # broadcast server
#broadcastclient # broadcast client
#broadcast 22.214.171.124 autokey # multicast server
#multicastclient 126.96.36.199 # multicast client
#manycastserver 188.8.131.52 # manycast server
#manycastclient 184.108.40.206 autokey # manycast client
# Enable public key cryptography.
Once the configuration file is open, add “ph.pool.ntp.org” as indicated above. It must be noted that there are a lot of available Network Time Protocol servers on the internet. Save the file.
For a complete list, check this link: http://www.pool.ntp.org/zone/asia.
To apply the changes the NTP daemon must be restarted. On the terminal, type this:
#service ntpd restart
Synchronize the System Clock with the NTP Servers