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.
- Install NTPD: Run the below command to install ntpd via yum.
- [root@server ~]# yum install ntp
- Update NTPD Configuration: Modify the ntpd.conf file located in the /etc/ directory.
- [root@server ~]# vi /etc/ntp.conf
- # 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
- restrict default kod nopeer notrap nomodify
- restrict -6 default kod nopeer notrap nomodify
- # 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 127.0.0.1
- restrict -6 ::1
- # Use public servers from the pool.ntp.org project.
- # Please consider joining the pool (http://www.pool.ntp.org/join.html).
- server 0.rhel.pool.ntp.org
- server 1.rhel.pool.ntp.org
- server 2.rhel.pool.ntp.org
- # Undisciplined Local Clock. This is a fake driver intended for backup
- # and when no outside source of synchronized time is available.
- server 127.127.1.0 # local clock
- fudge 127.127.1.0 stratum 10
- # Drift file. Put this in a directory which the daemon can write to.
- # No symbolic links allowed, either, since the daemon updates the file
- # by creating a temporary in the same directory and then rename()'ing
- # it to the file.
- driftfile /var/lib/ntp/drift
- Set NTPD to Start: Update chkconfig to have ntpd start when the server restarts.
- [root@server ~]# chkconfig ntpd on
- [root@server ~]# chkconfig --list | grep ntp
- Update Server Time: Use rdate to set the server time. Install it if it is not already installed.
- [root@server ~]# yum install rdate
- [root@server ~]# rdate -s cuckoo.nevada.edu
- Start NTPD: Run the below command to start NTP (Network Time Protocol).
- [root@server ~]# /etc/init.d/ntpd start
- [root@server ~]# ps -ef | grep ntp
- ntp 15120 1 0 21:50 ? 00:00:00 ntpd -u ntp:ntp -p /var/run/ntpd.pid -g
- root 20420 19746 0 22:44 pts/3 00:00:00 grep ntp
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.
Use the below command to verify NTPD is now running. You should see output similar to what is below the ps command.
On this page you can check if your own NTP server is reachable over the internet:
http://www.vanheusden.com/time/query_ntp.php
It dont work. I change the date and wait NTP set it, but there is no change. I need to change it manualy.
The process to change the automated ntp query frequency missing.
Hello Olorim,
What part is not working for you? If you could post the specific response or anything from the logs we may be able to provide some assistance as the above directions do work in general and I have used the same process on many servers.
If it is already figured out we would love to hear the solution.
Thanks.
alex
Thank’s for your response.
I find the problem : It’s an older version of NTPD that you have in CentOS. This version dont support the option dynamic in /etc/ntp.conf.
That’s why it dont work.
I dont find how to regul the frequency of synchronization.
Hello Olorim,
I might not be understanding the problem here but the nature of NTPD is to constantly stay in sync so its not something you need to set. NTPD will automatically be checking the specified time source to make sure it is in sync.
If I am not understanding your question please feel free to respond.
Thanks.
alex