CentOS / Red Hat Configure an NTP Client And Server

How do I configure an NTP (Network Time Protocol) client or server under CentOS / RHEL / Fedora Linux to manage the system clock over a network?

The Network Time Protocol (NTP) is used to synchronize a computer’s time with another reference time source. Under CentOS / RHEL you can use NTP or OpenNTPD server software. Both package provides client and server software programs for time synchronization.

Install ntp

The ntp package contains utilities and daemons that will synchronize your computer’s time to Coordinated Universal Time (UTC) via the NTP protocol and NTP servers. The ntp packageincludes ntpdate (a program for retrieving the date and time from remote machines via a network) and ntpd (a daemon which continuously adjusts system time). Install the ntp package:
# yum install ntp

How do I configure an NTP Client?

Simply open /etc/ntp.conf file, enter:
# vi /etc/ntp.conf
Make sure the following line exists:
server ntp.server.com

  • ntp.server.com : the hostname or IP address of the site NTP server. If your ntp server located at, enter server You can also use public ntp server located at ntp.org.

You can also run ntpd using cron:
# echo '30 * * * * root /usr/sbin/ntpd -q -u ntp:ntp' > /etc/cron.d/ntpd
The above instructs crond to run ntpd and after setting the clock just exit, and the -u option instructs it to run as the ntp user.

Configure an NTP Server

If you have lots of server and desktop system, configure your own NTP server. Your NTP server contacts a central NTP server,provided by your ISP or a public time
server located at ntp.org, to obtain accurate time data. The server then allows other machines on your network to request the time data. Our sample setup:            ==> CentOS / Fedora / RHEL NTPD Server.              ==> ISP remote NTP server.        ==> NTP clients including desktop systems.

First, install and enable ntpd on
# yum install ntp
# chkconfig ntpd on

Now open /etc/ntp.conf:
# vi /etc/ntp.conf
Make sure the following line exits:
restrict default ignore
Above will deny all access to any machine, server or client. However, you need to specifically authorized policy settings. Set it as follows:

restrict mask nomodify notrap noquery

Replace and mask with actual remote ISP or ntp.org NTP server IP. Save and close the file.

Configure NTP clients to access your NTP Server

Now, you need to allow legitimate NTP clients to access the Server. For example, allow network to synchronize to this server located at Open /etc/ntp.conf and add policy as follows:

# Hosts on local network are less restricted.
restrict mask nomodify notrap

Update your firewall settings, open /etc/sysconfig/iptables.
# vi /etc/sysconfig/iptables
Add the following line, before the final LOG and DROP lines for the RH-Firewall-1-INPUT chain:

 -A RH-Firewall-1-INPUT -s -m state --state NEW -p udp --dport 123 -j ACCEPT

Save and close the file. Finally, start ntpd:
# service ntpd start
# service iptables restart
# netstat -tulpn

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 24 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
24 comments… add one
  • Tapas Mallick Mar 18, 2009 @ 10:46

    Nice tutorial. Could you please discuss about secure NTP based on “Key Based” security. Regards, Tapas.

  • KHIZAR May 27, 2009 @ 7:49

    Good tutorial, but discuss ntp in more detail thank you
    regards Khizar Saeed Khan

  • Eduardo Costa Jul 23, 2009 @ 20:31

    Excellent post! This is the smallest tutorial I ever found about NTP… Very easy to follow! Solved a lot of doubts I had about configuring the client… Thanks a lot!

  • Miguel Verdugo Oct 29, 2009 @ 15:46

    Very good tutorial. Thanks.

  • Mario Nov 24, 2009 @ 12:24

    Although you can set the time by running ntp in a cron job, this is seriously not recommended for anything but a simple home setup.

    For anything setup for work-related services, rather set the time through the NTP service. This will skew the time in a safer way than making a big time change in case the time has gone completely out since the last cron run.

  • razor Apr 13, 2010 @ 17:09

    Great tutorial.. saved me lots of time. Thanks

  • rmedster Jun 30, 2010 @ 13:21

    How to make ntp-client to send a time-request from a particular interface?

  • kaliram sahu Jul 14, 2010 @ 12:31

    i have faced a error an ntp server configuration. your system is not reach syncronize time. but some time autometic reach server.
    how to reach ntp properly,. i am user server ntpd restart , ntpq -indp ,and ntpdate command but not solve my problem.
    please solve this problem.

  • Nir Jan 7, 2011 @ 21:47

    Excellent tutorial as always.

    thank you.

  • temuri Jun 24, 2011 @ 13:35

    HI I have NTP server, and wants to send data with rs232 to windows 2000 workstation
    can someone help me ?


  • LCAlvarez Jun 24, 2011 @ 18:09

    Excellent, thanks a lot from Panama, PTY 507

    Excelente, muchas gracias desde Panamá

  • Samuel Sep 12, 2011 @ 12:16

    Unable to synchronise meinberg NTP time server to clients

    Below is the NTP configuration file

    # NTP Network Time Protocol
    # **** ATTENTION ****: *You have to restart the NTP service when you change this file to activate the changes*
    # Configuration File created by Windows Binary Distribution Installer Rev.: 1.26 mbg
    # please check http://www.ntp.org for additional documentation and background information
    # Use drift file
    #driftfile “C:\Program Files\NTP\etc\ntp.drift”
    #broadcastdelay 0.008

    # your local system clock, should be used as a backup
    # (this is only useful if you need to distribute time no matter how good or bad it is)
    # but it operates at a high stratum level to let the clients know and force them to
    # use any other timesource they may have.
    fudge stratum 12

    #driftfile /etc/ntp.drift
    driftfile “C:\Program Files\NTP\etc\ntp.drift”
    broadcastdelay 0.008

    broadcastclient yes

    # Use a NTP server from the ntp pool project (see http://www.pool.ntp.org)

    server ntp.a-lab.fi iburst

    # allow localhost

    # Please note that you need at least four different servers to be at least protected against

    server iburst
    #accept packets from
    restrict mask nomodify notrap
    restrict mask nomodify notrap

    # one falseticker. If you only rely on internet time, it is highly recommended to add
    # additional servers here.
    # The ‘iburst’ keyword speeds up initial synchronization, please check the documentation for more details!
    server 0.fi.pool.ntp.org minipoll 10 iburst
    server 1.fi.pool.ntp.org minpoll 10 iburst
    #server 2.fi.pool.ntp.org iburst
    #server 1.se.pool.ntp.org iburst
    #server 0.de.pool.ntp.org iburst

    # End of generated ntp.conf — Please edit this to suite your needs

    #Section insert by NTP Time Server Monitor 30.8.2011

    enable stats
    statsdir “C:\Program Files\NTP\etc\”
    statistics loopstats

    And also the NTP status is shown below

    State Remote Refid Stratum Type When Poll Reach Delay Offset Jitter
    LOCAL(1) LOCL 12 Local clock 51 64 003 0.000 0.000 0.001
    * 2 Unicast server 50 64 003 16.149 4.178 0.482 INIT 16 Unicast server 1023d 64 000 0.000 0.000 0.000
    + 2 Unicast server 96 1024 001 6.086 -5.366 0.115

    Kindly make the neccessary corrections for

  • Graham Lerant Sep 28, 2011 @ 13:10

    Very nice walkthrough.
    Especially the IPtables section.
    It’s usually easy to configure the server – quite another thing to achieve connectivity!

  • Jason Jun 27, 2012 @ 19:14

    Is it possible to allow multiple IP ranges in the IPtables? I tried multiple lines, but it had an error saying that is not allowed.

  • Andre Jul 2, 2012 @ 18:13

    I have been looking on the net everywhere for a decent tutorial for setting up NTP to no avail.
    I have a RHEL 6 host install. I created 2 RHEL 6 VMs with IP & .11
    I have been trying to get the .11 client to use the .10 as its NTP server. I have tried following dozens of instructions, but have always gotten ” no server suitable for syncronization found.
    Leaving the default data in each ntp.conf file…i have tried following several different instructions that basically have been saying the same thing as above…but still cant connect.
    The machines can ping each other yet cannot connect for NTP. I have added the port 123 udp in the firewall to allow that to be open.

    Can anyone provide assistance to anything that I may be ommiting. Can I try deleting/commenting all the default content and just insert statements suggested?


  • Chandan Oct 12, 2012 @ 22:07

    You are just amazing. You got every answer to our daily sysadmin work items. Thanks for all your posts.

  • Nikila Mar 21, 2013 @ 9:07

    I wanted to know how could I configure an NTP client using IPv6 address?
    Currently my ntp version is
    ntpd – NTP daemon program – Ver. 4.2.4p4

  • Jim Apr 17, 2013 @ 6:53

    One more question – you descibe how to configure an ntp client really well. But on a Linux system, how do you tell it to actually use ntp for its clock. Merely having the client running doesnt mean the system will use it.

  • Robert May 8, 2013 @ 13:31


    Good tutorial but how to test if ntp is working correctly?
    yuo can test with:
    ntpq -pn
    ntpq -p

    Also it is not clear in wich order the access rules must be placed.

    • Alex Jan 15, 2017 @ 13:40

      Thank you so much!!!

  • Dinesh Feb 18, 2014 @ 7:24

    Please mentoined below step for standalone server.

    If the server you are setting up do not have internet connection, you can synchronize it with the local time of the server itself. Just comment the server part, and change it to The sratum level is for determining what level this time server is set up for. Stratum 0 usually refers to real clock, for example atomic (cesium, rubidium) clocks or GPS clocks or other radio clocks. Stratum 1 is the machine connected to stratum 0 devices.

    #server mst.sirim.my prefer
    #server my.pool.ntp.org
    fudge stratum 10

  • flyerfan Oct 6, 2014 @ 17:01

    Any help on using a GPS connection from the serial input tty0?


  • James Mar 16, 2015 @ 16:33


    The mask should be



  • Premnath Bangar Feb 4, 2016 @ 16:33

    Dear Team,

    Please let me know how to configure Replication of NTP Server.

    Premnath Bangar.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum