Install NTP
sudo yum install ntp
Start NT
sudo /etc/init.d/ntpd start
Configure NTP servers
Select NTP server which close to your location from area list.
http://support.ntp.org/bin/view/Servers/NTPPoolServers
sudo vi /etc/ntp.conf
Replace default NTP servers.
server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org
to
server 0.north-america.pool.ntp.org
server 1.north-america.pool.ntp.org
server 2.north-america.pool.ntp.org
server 3.north-america.pool.ntp.org
Restart NTP
sudo /etc/init.d/ntp stop
sudo /etc/init.d/ntp start
Check sync status.
ntpstat
unsynchronised
time server re-starting
polling server every 64 s
If just started NTP, it won't start synchronize, it will take 10 or more minutes to start syncronizing.
If successfully synchorised, you will see messages like this.
synchronised to NTP server (180.235.254.234) at stratum 3
time correct to within 30 ms
polling server every 64 s
Configure automatic run. at booting.
sudo /sbin/chkconfig ntpd on
sudo /sbin/chkconfig --list
ntpd
ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Note.
NTP uses UDP port 123 to synchronize.
If you have filtered this port, you have to open port 123.
To open this port you can open with the following iptables arguments.
-I INPUT -p udp --dport 123 -j ACCEPT
-I OUTPUT -p udp --sport 123 -j ACCEPT