Install and Configure NTP on CentOS 5.X

This is just a brief howto about installing and configuring NTPD (Network Time Protocol Daemon) on a Linux server which in this case is specifically NTPD. First we will install ntpd, then update the current time on the server, configure ntpd to restart on server boot, and then start ntpd.

  1. Install NTPD: Run the below command to install ntpd via yum.
  2. bash

    1. [root@server ~]# yum install ntp

  3. Update NTPD Configuration: Modify the ntpd.conf file located in the /etc/ directory.
  4. bash

    1. [root@server ~]# vi /etc/ntp.conf

    Add the below to the /etc/ntp.conf file. Please be aware that there are many configuration options that can be added to /etc/ntp.conf that make it more secure and the below is a very basic configuration file.


    1. # Permit time synchronization with our time source, but do not
    2. # permit the source to query or modify the service on this system.
    3. # restrict default kod nomodify notrap nopeer noquery
    4. # restrict -6 default kod nomodify notrap nopeer noquery
    5. restrict default kod nopeer notrap nomodify
    6. restrict -6 default kod nopeer notrap nomodify
    8. # Permit all access over the loopback interface. This could
    9. # be tightened as well, but to do so would effect some of
    10. # the administrative functions.
    11. restrict
    12. restrict -6 ::1
    14. # Use public servers from the project.
    15. # Please consider joining the pool (
    16. server
    17. server
    18. server
    20. # Undisciplined Local Clock. This is a fake driver intended for backup
    21. # and when no outside source of synchronized time is available.
    22. server # local clock
    23. fudge stratum 10
    25. # Drift file. Put this in a directory which the daemon can write to.
    26. # No symbolic links allowed, either, since the daemon updates the file
    27. # by creating a temporary in the same directory and then rename()'ing
    28. # it to the file.
    29. driftfile /var/lib/ntp/drift
  5. Set NTPD to Start: Update chkconfig to have ntpd start when the server restarts.
  6. bash

    1. [root@server ~]# chkconfig ntpd on
    2. [root@server ~]# chkconfig --list | grep ntp
  7. Update Server Time: Use rdate to set the server time. Install it if it is not already installed.
  8. bash

    1. [root@server ~]# yum install rdate
    2. [root@server ~]# rdate -s
  9. Start NTPD: Run the below command to start NTP (Network Time Protocol).
  10. bash

    1. [root@server ~]# /etc/init.d/ntpd start

    Use the below command to verify NTPD is now running. You should see output similar to what is below the ps command.


    1. [root@server ~]# ps -ef | grep ntp
    2. ntp 15120 1 0 21:50 ? 00:00:00 ntpd -u ntp:ntp -p /var/run/ -g
    3. root 20420 19746 0 22:44 pts/3 00:00:00 grep ntp