Skip to content

Synchronize CentOS System Clock with Network Time Protocol (NTP)

Synchronize System Clock with Network Time Protocol (NTP) in CentOS

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.

Install NTPD

If  ntp is not installed in your CentOS box, here’s how to do it with yum:

#yum install ntp

Configuration NTPD

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:

#vi /etc/ntp.conf

 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).

driftfile /var/lib/ntp/drift

# 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 mask nomodify notrap

# Use public servers from the project.
# Please consider joining the pool (
server iburst
server iburst
server iburst
server iburst

#broadcast autokey                 # broadcast server
#broadcastclient                                                # broadcast client
#broadcast autokey                         # multicast server
#multicastclient                               # multicast client
#manycastserver                # manycast server
#manycastclient autokey  # manycast client

# Enable public key cryptography.

includefile /etc/ntp/crypto/pw

Once the configuration file is open, add “” 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:

Restart NTPD

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



Comments are closed.