return to Solaris

NTP
Network Time Protocol

Solaris 10 includes Network Time Protocol v3:
SUNWntpr      NTP (root)      Version 11.10.0, Rev= 2005.01.21.15.53
SUNWntpu      NTP (user)      Version 11.10.0, Rev= 2005.01.21.15.53


General Operation:
An NTP Client gets time-of-day updates from an NTP Server.
The NTP Client adjusts its internal clock to match the corrent time-of-day.
The NTP Client determines exactly how much (+/- drift) its internal clock is off from "perfection".
The NTP Client then can adjust its internal clock very slightly (+/- drift) to maintain absolute accuracy.

An NTP Server is simply an NTP Client that also answers incoming NTP requests.

Stratum 0 = reference clocks  - i.e. the
F-1 U.S. Atomic Clock in Boulder, Colorado
Stratum 1 = clocks synced to a Stratum 0 reference - usually private
Stratum 2 = a clock syncronized to a Stratum 1 clock - many are publicly available on the internet
                     in most cases, you would sync your own NTP Server to a Stratum 2 time server
                     then, configure the other hosts on your LAN as NTP Clients of your NTP Server
Stratum 3 = our NTP Server
Stratum 4 = NTP Clients on our LAN



Files needed for NTP to operate:
/etc/inet/ntp.conf            Lists configuration options for NTP
/etc/inet/ntp.client          Sample configuration file for NTP clients
/etc/inet/ntp.server        Sample configuration file for NTP servers
/etc/inet/ntp.drift            Sets the initial frequency offset on NTP servers
/etc/inet/ntp.keys           Contains the NTP authentication keys
/usr/lib/inet/xntpd           NTP daemon. See xntpd(1M) for more information
/usr/sbin/ntpdate            Utility to set the local date and time, based on NTP
                                             See ntpdate(1M) for more information
/usr/sbin/ntpq                 NTP query program. See ntpq(1M) for more information
/usr/sbin/ntptrace           Program to trace NTP hosts back to the master NTP server
                                             See ntptrace(1M) for more information
/usr/sbin/xntpdc             NTP query program for the xntpd daemon
                                             See xntpdc(1M) for more information
/var/ntp/ntpstats            Directory for holding NTP statistics



Starting and Stopping NTP on a Solaris 10 system






The configuration file /etc/inet/ntp.conf

Create one from scratch, or use /etc/inet/ntp.server or /etc/inet/ntp.client as a template
# cp /etc/inet/ntp.server /etc/inet/ntp.conf
#
# ls -la /etc/inet/ntp.conf
-rw-r--r--  1 root        sys                2809 Jan 21   2005  /etc/inet/ntp.conf
#


Key entries in the ntp.conf file:

for both client and server:

restrict default ignore
restrict 127.0.0.1

an NTP client may have just one NTP server on the local LAN which it uses as a time reference:
server baba.billhance.com
restrict 192.168.0.4 nomodify

an NTP server could have a statement allowing just the local network to query it:

restrict 192.168.0.0 mask 255.255.0.0 notrust nomodify notrap

an NTP server might have several server statements, referencing multiple external time servers:
server louie.udel.edu
restrict 128.4.40.12 nomodify

server clock.psu.edu
restrict 128.118.25.3 nomodify

server sundial.columbia.edu
restrict 128.59.59.117

for both client and server:
server 127.127.1.0
fudge 127.127.1.0 stratum 10

for both client and server:
driftfile /var/ntp/ntp.drift
(a Solaris NTP Client may not need a drift file)

for both client and server:
keys /etc/inet/ntp.keys
trustedkey 0
requestkey 0
controlkey 0
(a Solaris NTP Client may not need to use keys or a keys file)

for both client and server:
statsdir /var/ntp/ntpstats/
filegen peerstats file peerstats type day enable
filegen loopstats file loopstats type day enable
filegen clockstats file clockstats type day enable
(a Solaris NTP Client may not need logging)

When the NTP service is first started, the ntpstats directory and log files are created automatically
/var/ntp/ is owned by root/sys, with protection = 755
/var/ntp/ntpstats/ is owned by root/sys/, with protection = 755
The log files are owned by root/root, with protections = 644






The NTP daemon xntpd
The xntpd daemon reads /etc/inet/ntp.conf at startup

Start the xntpd daemon
# svcadm enable network/ntp
#


If you make changes to /etc/inet/ntp.conf, and you want NTP to re-read the service configuration

Refresh the NTP service

# svcs network/ntp
STATE STIME FMRI
online 18:55:14 svc:/network/ntp:default
#
# svcadm refresh network/ntp
#
# svcs network/ntp
STATE STIME FMRI
online 19:41:26 svc:/network/ntp:default
#
#





Using ntpq

# ntpq
ntpq> version
ntpq 3-5.93e Mon Sep 20 15:45:42 PDT 1999 (1)
ntpq> exit
#






Starting and Starting NTP on a Solaris 10 system


Starting the NTP service

# svcadm enable network/ntp
#

Checking the NTP service

# svcs network/ntp
STATE          STIME    FMRI
online         12:37:41 svc:/network/ntp:default
#

Watching NTP sync itself with eternal sources
Immediately after the initial start of the NTP service

# ntpq
ntpq> peers
     remote          local    st t when poll reach delay offset      disp
=========================================================================
 LOCAL(0)          0.0.0.0    10 -    -   64    0  0.00   0.000   16000.0
 louie.udel.edu    0.0.0.0    16 -    -   64    0  0.00   0.000   16000.0
 otc2.psu.edu      0.0.0.0    16 -    -   64    0  0.00   0.000   16000.0
 hickory.cc.colu   0.0.0.0    16 -    -   64    0  0.00   0.000   16000.0
ntpq> exit
#

peers =
print a list of the server's peers

1 minute after the initial start of the NTP service:

# ntpq
ntpq> peers
     remote          refid       st t when poll reach delay offset   disp
=========================================================================
 LOCAL(0)        LOCAL(0)        10 -   -   64     0  0.00   0.000 16000.0
 louie.udel.edu  NAVOBS1.MIT.EDU  2 u  44   64     1 16.07 -62.149 15875.0
 otc2.psu.edu    otc1.psu.edu     2 u  44   64     1 44.07 -61.212 15875.0
 hickory.cc.colu navobs1.wustl.e  2 u  44   64     1 26.78 -62.341 15875.0
ntpq> exit
#


3 minutes after the initial start of the NTP service:

# ntpq
ntpq> peers
     remote          refid       st t when poll reach delay offset   disp
=========================================================================
 LOCAL(0)        LOCAL(0)        10 -   -   64     0  0.00   0.000 16000.0
 louie.udel.edu  NAVOBS1.MIT.EDU  2 u   1   64    17 16.11 -62.771 1875.26
 otc2.psu.edu    otc1.psu.edu     2 u   1   64    17 44.78 -56.157 1877.15
 hickory.cc.colu navobs1.wustl.e  2 u   1   64    17 21.80 -59.975 1875.61
ntpq> exit
#

10-12 minutes after the initial start of the NTP service:

# ntpq
ntpq> peers
     remote          refid       st t when poll reach delay offset   disp
=========================================================================
  LOCAL(0)       LOCAL(0)        10 -   -   64     0  0.00   0.000 16000.0
*louie.udel.edu  NAVOBS1.MIT.EDU  2 u  37  128   377 16.22  -5.897    4.52
+otc2.psu.edu    otc1.psu.edu     2 u  43  128   377 42.08  12.840    5.95
+hickory.cc.colu navobs1.wustl.e  2 u  36  128   377 16.19  -5.119    6.38
ntpq>
ntpq>
ntpq> rv
status=0644 leap_none, sync_ntp, 4 events, event_peer/strat_chg
system="SunOS", leap=00, stratum=3, rootdelay=26.54,
rootdispersion=69.41, peer=11829, refid=louie.udel.edu,
reftime=c6a35d5e.af99f000 Tue, Aug 9 2005 12:50:38.685, poll=7,
clock=c6a35d8a.203a4000 Tue, Aug 9 2005 12:51:22.125, phase=0.824,
freq=4322.48, error=18.57
ntpq>
ntpq> exit
#

rv = read system variables
     This system is now reliably getting its time from a stratum 2
     time server (louie.udel.edu), so it lists itself as stratum=3.


Notice the "*" and "+".  These are Tally Codes
*  The peer has been declared the system peer, and lends its variables
     to the system variables.
+  The peer is a survivor and a candidate for the combining algorithm.
-  The peer is discarded by the clustering algorithm as an outlyer.
x  The peer is discarded by the intersection algorithm as a falseticker.

3 1/2 hours after the initial start of the NTP service:

#
# ntpq
ntpq> peers
     remote          refid       st t when poll reach delay offset   disp
=========================================================================
  LOCAL(0)       LOCAL(0)        10 -   -   64     0  0.00   0.000 16000.0
*louie.udel.edu  rackety.udel.ed  2 u 664 1024   377 16.63 -10.263   20.43
+otc2.psu.edu    otc1.psu.edu     2 u 662 1024   377 42.36 -27.244   50.06
+hickory.cc.colu NAVOBS1.MIT.EDU  2 u 146 1024   377 16.80 -13.472    6.21
ntpq>
ntpq> rv
status=0644 leap_none, sync_ntp, 4 events, event_peer/strat_chg
system="SunOS", leap=00, stratum=3, rootdelay=17.35,
rootdispersion=149.02, peer=11829, refid=louie.udel.edu,
reftime=c6a3867d.b1775000 Tue, Aug 9 2005 15:46:05.693, poll=10,
clock=c6a3891e.cb6a9000 Tue, Aug 9 2005 15:57:18.794, phase=2.301,
freq=942.44, error=53.30
ntpq>
ntpq> exit
#
#

 

One day after the initial start of the NTP service:

# ntpq
ntpq> peers
     remote          refid       st t when poll reach delay offset   disp
=========================================================================
 LOCAL(0)        LOCAL(0)        10 -   -   64     0  0.00   0.000 16000.0
*louie.udel.edu  NAVOBS1.MIT.EDU  2 u 332 1024   377 17.38   0.061    9.58
xotc2.psu.edu    otc1.psu.edu     2 u 330 1024   377 41.92 -160.21   87.36
+hickory.cc.colu ntp2.usno.navy.  2 u 838 1024   377 15.61   1.535    6.04
ntpq>
ntpq> rv
status=0644 leap_none, sync_ntp, 4 events, event_peer/strat_chg
system="SunOS", leap=00, stratum=3, rootdelay=27.18,
rootdispersion=117.83, peer=11829, refid=louie.udel.edu,
reftime=c6a5027d.b1054000 Wed, Aug 10 2005 18:47:25.691, poll=10,
clock=c6a503d3.983a7000 Wed, Aug 10 2005 18:53:07.594, phase=1.166,
freq=-175.67, error=10.68
ntpq>
ntpq> exit
#


Several days later...

# date
Sat Aug 13 12:51:24 EDT 2005
#
# ntpq
ntpq>
ntpq> lopeers
remote local st t when poll reach delay offset disp
===========================================================================
LOCAL(0) 0.0.0.12 10 - - 64 0 0.00 0.000 16000.0
+louie.udel.edu 192.168.0.4 2 u 120 1024 377 31.30 1.046 1.45
+otc2.psu.edu 192.168.0.4 2 u 878 1024 377 42.72 11.891 22.38
*hickory.cc.colu 192.168.0.4 2 u 73 1024 377 24.51 -0.773 1.27
ntpq>
ntpq> peers
remote refid st t when poll reach delay offset disp
==============================================================================
LOCAL(0) LOCAL(0) 10 - - 64 0 0.00 0.000 16000.0
+louie.udel.edu ntp0.usno.navy. 2 u 122 1024 377 31.30 1.046 1.45
+otc2.psu.edu otc1.psu.edu 2 u 880 1024 377 42.72 11.891 22.38
*hickory.cc.colu NAVOBS1.MIT.EDU 2 u 75 1024 377 24.51 -0.773 1.27
ntpq>
ntpq> rv
status=0654 leap_none, sync_ntp, 5 events, event_peer/strat_chg
system="SunOS", leap=00, stratum=3, rootdelay=31.27,
rootdispersion=21.36, peer=11831, refid=hickory.cc.columbia.edu,
reftime=c6a8a34b.b3884000 Sat, Aug 13 2005 12:50:19.701, poll=10,
clock=c6a8a399.71ed3000 Sat, Aug 13 2005 12:51:37.445, phase=1.413,
freq=-3966.98, error=9.74
ntpq>
ntpq> exit
#





NTP on Solaris 10
Network Time Protocol


Using ntpq to administer NTP

# ntpq
ntpq> version                                                prints the version number
ntpq 3-5.93e Mon Sep 20 15:45:42 PDT 1999 (1)
ntpq>
ntpq>
ntpq>
ntpq> readvar                                               readvar = rv = read system (or peer) variables



ntpq> quit
#





return to top
home

Copyright © billhance.com.  All rights reserved.