Network Time Protocol (NTP) server setup and configuration
The Protocol
Network Time protocol (NTP) is a Transport Layer (4) protocol used to synchronize time across networked devices to have consistent and unified time. It uses UDP port 123, and resists the effect of variable latency of packet-switched networks. Time sync is done using UTC (no time zone or daylight saving is provided) and each device adds its time zone and daylight saving (if different) to it.
NTP and SNTP
Simple Network Time Protocol (SNTP) is a less complex time sync protocol. Basically, this protocol (SNTP) does not store information about previous communication, nor it require high accuracy timing.
NTP Servers
NTP is a hierarchical system in terms of servers or clock sources. A stratum(level) determines it distance from the real clock source (GPS, atomic, etc…). Stratum 0 is the clock source itself, while stratum 1 is the directly connected NTP server to stratum 0. Stratum 2 servers are directly querying time from stratum 1 servers and so forth.
Linux NTPd Service
Linux has a native support for NTP. To enable it, just make sure NTP package is installed (RH, CentOS, and others) or check for /etc/ntp.conf file. Shut down NTPd service first (if it is running) by typing (for RH, CentOS):
# /etc/init.d/ntpd stop
Then edit the /etc/ntp.conf file adding/replacing these lines to it (based on where are you located):
server 0.de.pool.ntp.org
server 1.de.pool.ntp.org
server 2.de.pool.ntp.org
You can substitute your 2-letter ISO country’s name (de, uk, fr, etc…). Please refer to http://www.pool.ntp.org/ for list of available servers in your area.
Before starting NTPd service execute the following:
# ntpdate 0.de.pool.ntp.org
to sync the time initially and make the time difference minimal, then, alter the run level of the service to 345:
# chkconfig --level 345 ntpd on
Start the service:
# /etc/init.d/ntpd start
Leave it for 1 hour and then issue this command:
# ntpq -p
and the result should be similar to this:
remote refid st t when poll reach delay offset jitter
==============================================================================
+skywiley.com 173.14.47.149 2 u 851 1024 377 346.070 8.366 118.239
-mirror 128.105.39.11 3 u 763 1024 377 266.614 -9.626 3.613
+ntp2.csl.tjhsst 192.5.41.40 2 u 203 1024 377 266.569 -2.793 0.430
*barium.vps.bitf 193.190.230.66 2 u 869 1024 377 189.283 -2.613 0.287
