NTP Synchronize
NTP Synchronize
Overview
First approach
Following this hierarchy, the next level in the structure are the stratum 2
servers which in turn are the clients for stratum 1 servers. The lowest
level of the hierarchy is made up by stratum 16 servers. Generally
speaking, every server syncronized with a stratum n server is termed as
being at stratum n+1 level. So, there are a few stratum 1 servers which
are referenced by stratum 2 servers, wich in turn are refenced by
stratum 3 servers, which are referenced by stratum 4 and so on.
So, at this point we know that NTP clients can operate with NTP servers
in three ways:
in a client-server basis
in a peer to peer mode
sending the time using broadcast/multicast
Note that the path and/or name of these configuration files may vary in
your system. Check the -c command line option.
server 134.214.100.6
server swisstime.ee.ethz.ch
peer 192.168.100.125
peer 192.168.100.126
peer 192.168.100.127
driftfile /etc/ntp/drift
#multicastclient # listen on default 224.0.1.1
#broadcastdelay 0.008
authenticate no
#keys /etc/ntp/keys
#trustedkey 65535
#requestkey 65535
#controlkey 65535
# allow localhost
restrict 127.0.0.1 mask 255.255.255.255
References
NTP homepage
ntpd
Network time protocol (version 3) specification
Public NTP Time Servers
NTP Basics
NTP stands for Network Time Protocol, and it is an Internet protocol used to
synchronize the clocks of computers to some time reference. NTP is an
Internet standard protocol originally developed by Professor David L. Mills at
the University of Delaware.
SNTP (Simple Network Time Protocol) is basically also NTP, but lacks some
internal algorithms that are not needed for all types of servers.
As a consequence, isolated networks may run their own wrong time, but as soon as
you connect to the Internet, effects will be visible. Just imagine some EMail message
arrived five minutes before it was sent, and there even was a reply two minutes
before the message was sent.
NTP needs some reference clock that defines the true time to operate. All
clocks are set towards that true time. (It will not just make all systems agree
on some time, but will make them agree upon the true time as defined by
some standard.)
NTP uses UTC as reference time
NTP is a fault-tolerant protocol that will automatically select the best of several
available time sources to synchronize to. Multiple candidates can be combined
to minimize the accumulated error. Temporarily or permanently insane time
sources will be detected and avoided.
Having available several time sources, NTP can select the best candidates to
build its estimate of the current time. The protocol is highly accurate, using a
resolution of less than a nanosecond (about 2^-32 seconds). (The popular
protocol used by rdate and defined in [RFC 868] only uses a resolution of one
second).
Universal means that the time can be used everywhere in the world, meaning
that it is independent from time zones (i.e. it's not local time). To convert UTC
to local time, one would have to add or subtract the local time zone.
In this example we show, how to synchronize your Linux, Solaris and Windows 2000
Server (Primary Domain Controller) with the Public NTP Time Server:
swisstime.ethz.ch
Configuration on Unix
The NTP client program ntpdate sets the system clock once. As real clocks drift, you
need periodic corrections. Basically you can run ntpdate in a cron job hourly or daily,
but your machine won't be an NTP server then.
0 2 * * * /usr/sbin/ntpdate -s -b -p 8 -u 129.132.2.21
-b
Force the time to be stepped using the settimeofday() system
call, rather than slewed (default) using the adjtime() system
call. This option should be used when called from a startup
file at boot time.
-p samples
-s
-u
First of all you have to download the NTP sources from www.ntp.org. On RedHat
Linux 7.0 / 7.1 the NTP server ntpd is already included in the distribution.
The NTP server ntpd will learn and remember the clock drift and it will correct it
autonomously, even if there is no reachable server. Therefore large clock steps can
be avoided while the machine is synchronized to some reference clock. In addition
ntpd will maintain error estimates and statistics, and finally it can offer NTP service
for other machines.
start() {
# Adjust time to make life easy for ntpd
if [ -f /etc/ntp/step-tickers ]; then
echo -n $"Synchronizing with time server: "
/usr/sbin/ntpdate -s -b -p 8 -u \
`/bin/sed -e 's/#.*//' /etc/ntp/step-tickers`
success
echo
fi
# Start daemons.
echo -n $"Starting $prog: "
daemon ntpd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ntpd
return $RETVAL
}
Insert swisstime.ethz.ch or more NTP Servers to /etc/ntp/step-tickers
129.132.2.21
# /etc/rc.d/init.d/ntpd start
Troubleshooting
One of the quickest commands to verify that ntpd is still up and running as desired
is ntpq -p. That command will show all peers used and configured together with their
corner performance data.
# ntpq -p
To obtain a current list peers of the server, along with a summary of each peer's
state. Summary information includes the address of the remote peer, the reference
ID (0.0.0.0 if this is unknown), the stratum of the remote peer, the type of the peer
(local, unicast, multicast or broadcast), when the last packet was received, the
polling interval, in seconds, the reachability register, in octal, and the current
estimated delay, offset and dispersion of the peer, all in milliseconds.
# ntpdc
ntpdc> peers
Be sure that there is an entry for the the swisstime.ethz.ch server, and that there is
an entry for your local net. The "st" (stratum) column for the ITD time servers
should be "1" or "2", indicating that the time server are stratum-1/2 servers, e.g.
they obtain their time from stratum-1 servers, which are directly connected to
external time reference sources. If the stratum for any server is "16" then this
server is not synchronizing successfully.
You can also set the start option of the Windows Time Synchronization
Service (W32Time) to Automatic, so the service will start when
Windows/2000 starts.
Set the following Registry Entries for the W32Time Service (marked in blue
color)
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters
LocalNTP : REG_DWORD
Used to start the SNTP server.
0 = do not start the SNTP server unless this computer is a domain controller
[default]
1 = always start the SNTP server
Type : REG_SZ
Used to control how a computer synchronizes.
Nt5DS = synchronize to domain hierarchy [default]
NTP = synchronize to manually configured source
NoSync = do not synchronize time
The Adj and msSkewPerDay values are used to preserve information about the
computer's clock between restarts. Do not manually edit these values.
More Information
http://www.eecis.udel.edu/~ntp/