Configuring NTP on CentOS 6 (and similar versions) involves a number of steps - especially if you want to have it configured right and secure. Here's a quick guide how to do it:
First of all you have to determine the IP addresses of the NTP servers you are going to use. You may have to contact your network administrator to find out. Ensure that you get at least two time server IP addresses to use.
Then, install and verify the NTP packages:
Edit file /etc/ntp.conf and ensure that option "broadcastclient" is commented out (which it is by default with a new installation).# yum -y install ntp ntpdate # yum -q ntp ntpdate
Enable ntp and ntpdate at system boot time:
Ensure that file /etc/ntp/step-tickers is empty. This will make sure that if ntpdate is run, that it will use one of the time servers configured in /etc/ntp.conf.# chkconfig ntpd on # chkconfig ntpdate on
Add two time servers to /etc/ntp.conf, or use any of the pre-configured time servers in this file. Comment out the pre-configured servers, if you are using your own time servers.# cp /dev/null /etc/ntp/step-tickers
Do not copy the example above. Use the IP addresses for each time server that you've received from your network administrator instead.#server 0.centos.pool.ntp.org iburst #server 1.centos.pool.ntp.org iburst #server 2.centos.pool.ntp.org iburst #server 3.centos.pool.ntp.org iburst server 1.2.3.4 server 5.6.7.8
Enable NTP slewing (for slow time stepping if the time on the server is off, instead of suddenly making big time jump changes), by adding "-x" to OPTIONS in /etc/sysconfig/ntpd. Also add "SYNC_HWCLOCK=yes" in /etc/sysconfig/ntpdate to synchronize the hardware clock with any time changes.
Stop the NTP service, if it is running:
Start the ntpdate service (this will synchronize the system clock and the hardware clock):# service ntpd stop
Now, start the time service:# service ntpdate start
Wait a few minutes for the server to synchronize its time with the time servers. This may take anywhere between a few and 15 minutes. Then check the status of the time synchronization:# service ntpd start
The asterisk in front of the time server name in the "ntpq -p" output indicates that the client has reached time synchronization with that particular time server.# ntpq -p # ntpstat
Done!
If you found this useful, here's more on the same topic(s) in our blog:
- Monitoring a log file through Systemd
- Securely enabling SNMP on Red Hat
- Using mkvgdata and restvg in DR situations
- Automating microcode discovery
- Automatic FTP
UNIX Health Check delivers software to scan Linux and AIX systems for potential issues. Run our software on your system, and receive a report in just a few minutes. UNIX Health Check is an automated check list. It will report on perfomance, capacity, stability and security issues. It will alert on configurations that can be improved per best practices, or items that should be improved per audit guidelines. A report will be generated in the format you wish, and the report includes the issues discovered and information on how to solve the issues as well.
Interested in learning more?
Interested in learning more?




