Keeping Sync with a Remote NTP Server

Posted: 18 May 2005

Background

All computers have their own internal clocks, implemented in hardware and software. These clocks have acceptable accuracy, but are not anywhere near perfect - they all exhibit "clock drift," letting their time drift by several seconds a day. While desktop users may not be inconvenienced by drift, system administrators cannot tolerate it. When running a server, it is essential to keep the system's time synchronized with the other servers it interacts with.

Linux provides a means to keep time in sync via the Network Time Protocol (NTP). A computer running the NTP client frequently probes one or more NTP servers and synchronizes its time with that of the server(s).

YaST provides a means to set-up one or more remote NTP server via the "NTP Client" module found under "Network Services." A list of public NTP servers can be found here. OES servers can also be configured to serve as NTP servers. See the Novell Network Time Protocol Administration Guide for OES (pdf) for more details.

The Problem

When adding a remote time source in YaST, there are always at least two sources added to /etc/ntp.conf: the local computer and the remote time source. When the NTP daemon starts, it initially synchronizes the system time to the time server's time, then periodically performs the same synchronization in the background. If the time server is not immediately available, then NTP falls back on the default local time source.

Some users have observed that their system time is being synchronized to the remote server's time when xntpd initially starts, but then is only being synchronized to their local time thereafter. An example /var/log/ntp would look like this:
2 May 08:11:05 ntpd[2965]: synchronized to LOCAL(0), stratum 10
2 May 08:11:05 ntpd[2965]: kernel time sync disabled 0041
2 May 08:14:17 ntpd[2965]: synchronized to LOCAL(0), stratum 10
2 May 08:26:13 ntpd[2965]: kernel time sync enabled 0001
2 May 10:33:35 ntpd[3489]: synchronized to LOCAL(0), stratum 10
2 May 10:33:35 ntpd[3489]: kernel time sync disabled 0041

Also, executing xntpdc -p would reveal that the time is synchronized to the LOCAL, not the remote server (see the entry with the '*').
#  xntpdc -p

     remote           local      st poll reach  delay   offset    disp
=======================================================================
*LOCAL(0)        127.0.0.1       10 1024  377 0.00000  0.000000 0.11856
=prv-time.provo. 137.65.211.18    2 1024  377 0.00041 -262.1380 0.11470

The Solution

The solution is to make NTP more persistent when probing the remote time server. This is done by appending the flags burst and iburst to the remote server; burst tells NTP to send a burst of eight packets to the remote server instead of one when the server is reachable, and iburst tells it to do the same when the server is not reachable. The result is faster and more reliable synchronizations.

These options can be added in the "NTP Client" YaST module by selecting "Complex Configuration" then editing the remote server. The options are added in the "Options" field and are space-delimited. They can also be added directly to the server in /etc/ntp.conf as follows:
server 137.65.1.123  burst iburst
A healthy /var/log/ntp will then look like this:
29 Apr 15:24:58 ntpd[6892]: synchronized to 137.65.1.123, stratum 2
29 Apr 15:24:58 ntpd[6892]: kernel time sync disabled 0041
29 Apr 15:26:15 ntpd[6892]: kernel time sync enabled 0001
2 May 08:10:41 ntpd[6892]: ntpd exiting on signal 15
2 May 08:13:33 ntpd[6684]: synchronized to 137.65.1.123, stratum 2
2 May 08:13:33 ntpd[6684]: kernel time sync disabled 0041
2 May 08:13:45 ntpd[6684]: kernel time sync enabled 0001



Informacja z serwisu http://www.djack.com.pl