How to synchronize time with NTP

NTP is a networking protocol which enables one to synchronize clock among different computers using IP packets. NTP is commonly used when you need to maintain a cluster of hosts as part of distributed compute and storage cloud, where clock synchrony is important for proper operations. NTP is capable of compensating for variable latency over networks, and can achieve clock synchronization with 1 millisecond accuracy under ideal conditions. If you would like to synchronize time on all hosts involved via NTP, you need to set up NTP client on each host, which is described as follows.

Install NTP Client on CentOS, RHEL or Fedora

First, install ntp with yum:

$ sudo yum install ntp

After that, start ntpd service and enable it to auto-start:

On CentOS/RHEL 6 or earlier:

$ sudo chkconfig ntpd on
$ sudo service ntpd start

On CentOS/RHEL 7 or later or Fedora:

$ sudo systemctl start ntpd.service
$ sudo systemctl enable ntpd.service

Install NTP Client on Ubuntu, Debian or Linux Mint

Install ntp with apt-get:

$ sudo apt-get install ntp

After installing NTP, NTP daemon process ntpd should automatically start running, and auto-start upon boot. If not, you can manually start it as follows.

$ sudo /etc/init.d/ntp start

Configure NTP Client

After you install ntp as above, edit /etc/ntp.conf to change NTP servers in the file as needed. Depending on where you are located, you may want to choose NTP servers located geographically close by. For example, if you are located in North America, you can set the following in /etc/ntp.conf.


For a list of available public NTP servers, check out:

Note that in case the clock on your host is significantly out of sync against NTP servers, it may take a long time for the host to drift to the correct current time, as the ntpd daemon process performs smooth clock adjustment over time. So if your clock is significantly incorrect, it is recommended that you synchronize time by running ntpdate manually. Note that before running ntpdate, you need to stop ntpd daemon first.

$ sudo ntpdate -u

Use NTP Behind Proxy or Firewall

NTP uses UDP packets with port number 123. So if your host is behind a corporate proxy or firewall, and the proxy or firewall blocks that port number, the public NTP servers you specify in /etc/ntp.conf won't be reachable to your host. So make sure that your host can reach the NTP servers on port 123, using UDP. When a corporate proxy or firewall is in place, typically there exist internal NTP servers set up by the company. So you should use those internal NTP servers instead.

Use NTP in the Virtual Machine (VM) Environment

If the host in question is a XenServer's guest VM, you need to set up ntpd on dom0 host machine, not on the gust VM itself. You won't be able to synchronize clock with NTP on XenServer VMs when clock on their dom0 is not up-to-date. Once you synchronize clock on dom0, time on guest VMs will automatically be sync-ed without setting up ntpd.

As far as VMware Server is concerned, host machine's clock and guest VM's clock can drift independently. So you need to set up ntpd on guest VMs, independent of the host machine.

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

One thought on “How to synchronize time with NTP

  1. Hi!
    I would like to setup NTP server to pass locally time onto router. As my router firmware does not allow DST setting.

    Any hints?

Leave a comment

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