freebsd-nq/sntp/sntp.html

453 lines
17 KiB
HTML
Raw Normal View History

<html lang="en">
<head>
<title>Sntp User's Manual</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Sntp User's Manual">
<meta name="generator" content="makeinfo 4.7">
<link title="Top" rel="top" href="#Top">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family: serif; font-weight: normal; }
--></style>
</head>
<body>
<h1 class="settitle">Sntp User's Manual</h1>
<div class="node">
<p><hr>
<a name="Top"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-Description">sntp Description</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#dir">(dir)</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#dir">(dir)</a>
<br>
</div>
<h2 class="unnumbered">Simple Network Time Protocol User Manual</h2>
<p>This document describes the use of the NTP Project's <code>sntp</code> program,
that can be used to query a Network Time Protocol (NTP) server and
display the time offset of the system clock relative to the server
clock. Run as root, it can correct the system clock to this offset as
well. It can be run as an interactive command or from a cron job.
<p>This document applies to version 4.2.6p5 of <code>sntp</code>.
<p>The program implements the SNTP protocol as defined by RFC 5905, the NTPv4
IETF specification.
<div class="shortcontents">
<h2>Short Contents</h2>
<ul>
<a href="#Top">Simple Network Time Protocol User Manual</a>
</ul>
</div>
<ul class="menu">
<li><a accesskey="1" href="#sntp-Description">sntp Description</a>: Description
<li><a accesskey="2" href="#sntp-Invocation">sntp Invocation</a>: Invoking sntp
<li><a accesskey="3" href="#Usage">Usage</a>: Usage
</ul>
<div class="node">
<p><hr>
<a name="sntp-Description"></a>
<br>
</div>
<!-- node-name, next, previous, up -->
<h3 class="section">Description</h3>
<p>By default, <code>sntp</code> writes the local data and time (i.e., not UTC) to the
standard output in the format:
<pre class="example"> 1996 Oct 15 20:17:25.123 +4.567 +/- 0.089 secs
</pre>
<p>where the +4.567 +/- 0.089 secs indicates the time offset and
error bound of the system clock relative to the server clock.
<div class="node">
<p><hr>
<a name="sntp-Invocation"></a>
<br>
</div>
<h3 class="section">Invoking sntp</h3>
<p><a name="index-sntp-1"></a><a name="index-standard-Simple-Network-Time-Protocol-program-2"></a>
<code>sntp</code>
can be used as a SNTP client to query a NTP or SNTP server and either display
the time or set the local system's time (given suitable privilege). It can be
run as an interactive command or in a
<code>cron</code>
job.
<p>NTP (the Network Time Protocol) and SNTP (the Simple Network Time Protocol)
are defined and described by RFC 5905.
<p class="indent">The default is to write the estimated correct local date and time (i.e. not
UTC) to the standard output in a format like
<pre class="example"> 1996-10-15 20:17:25.123 (+0800) +4.567 +/- 0.089 secs
</pre>
<p>where the
<pre class="example"> +4.567 +/- 0.089 secs
</pre>
<p>indicates the local clock is 4.567 seconds behind the correct time
(so 4.567 seconds must be added to the local clock to get it to be correct),
and the (local) time of
<code>1996-10-15 20:17:25.123</code>
can be converted to UTC time by adding 8 hours and 0 minutes, and
is believed to be correct to within
<code>+/- 0.089</code>
seconds.
<p>This section was generated by <strong>AutoGen</strong>,
the aginfo template and the option descriptions for the <span class="command">sntp</span> program. It documents the <span class="command">sntp</span> usage text and option meanings.
<p>This software is released under a specialized copyright license.
<ul class="menu">
<li><a accesskey="1" href="#sntp-usage">sntp usage</a>: sntp usage help (-?)
<li><a accesskey="2" href="#sntp-adjtime">sntp adjtime</a>: adjtime option (-j)
<li><a accesskey="3" href="#sntp-authentication">sntp authentication</a>: authentication option (-a)
<li><a accesskey="4" href="#sntp-broadcast">sntp broadcast</a>: broadcast option (-b)
<li><a accesskey="5" href="#sntp-ipv4">sntp ipv4</a>: ipv4 option (-4)
<li><a accesskey="6" href="#sntp-ipv6">sntp ipv6</a>: ipv6 option (-6)
<li><a accesskey="7" href="#sntp-keyfile">sntp keyfile</a>: keyfile option (-k)
<li><a accesskey="8" href="#sntp-kod">sntp kod</a>: kod option (-K)
<li><a accesskey="9" href="#sntp-logfile">sntp logfile</a>: logfile option (-l)
<li><a href="#sntp-normalverbose">sntp normalverbose</a>: normalverbose option (-d)
<li><a href="#sntp-settod">sntp settod</a>: settod option (-s)
<li><a href="#sntp-syslog">sntp syslog</a>: syslog option (-p)
<li><a href="#sntp-timeout">sntp timeout</a>: timeout option (-t)
</ul>
<div class="node">
<p><hr>
<a name="sntp-usage"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-adjtime">sntp adjtime</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>
<h4 class="subsection">sntp usage help (-?)</h4>
<p><a name="index-sntp-usage-3"></a>
This is the automatically generated usage text for sntp:
<pre class="example">sntp - standard Simple Network Time Protocol program - Ver. 4.2.6p5
USAGE: sntp [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]... \
[ hostname-or-IP ...]
Flg Arg Option-Name Description
-4 no ipv4 Force IPv4 DNS name resolution
- prohibits these options:
ipv6
-6 no ipv6 Force IPv6 DNS name resolution
- prohibits these options:
ipv4
-d no normalverbose Normal verbose
-K Str kod KoD history filename
-p no syslog Logging with syslog
- prohibits these options:
logfile
-l Str logfile Log to specified logfile
- prohibits these options:
syslog
-s no settod Set (step) the time with settimeofday()
- prohibits these options:
adjtime
-j no adjtime Set (slew) the time with adjtime()
- prohibits these options:
settod
-b Str broadcast Use broadcasts to the address specified for synchronisation
-t Num timeout Specify the number of seconds to wait for broadcasts
-a Num authentication Enable authentication with the key auth-keynumber
-k Str keyfile Specify a keyfile. SNTP will look in this file for the key specified with -a
opt version Output version information and exit
-? no help Display extended usage information and exit
-! no more-help Extended usage information passed thru pager
-&gt; opt save-opts Save the option state to a config file
-&lt; Str load-opts Load options from a config file
- disabled as --no-load-opts
- may appear multiple times
Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
The following option preset mechanisms are supported:
- reading file $HOME/.ntprc
- reading file ./.ntprc
- examining environment variables named SNTP_*
sntp implements the Simple Network Time Protocol, and is used to query an
NTP or SNTP server and either display the time or set the local system's
time (given suitable privilege).
It can be run interactively from the command line or as a cron job.
NTP and SNTP are defined by RFC 5905, which obsoletes RFC 4330 and RFC
1305.
please send bug reports to: http://bugs.ntp.org, bugs@ntp.org
</pre>
<div class="node">
<p><hr>
<a name="sntp-adjtime"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-authentication">sntp authentication</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-usage">sntp usage</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>
<h4 class="subsection">adjtime option (-j)</h4>
<p><a name="index-sntp_002dadjtime-4"></a>
This is the &ldquo;set (slew) the time with adjtime()&rdquo; option.
<p>This option has some usage constraints. It:
<ul>
<li>must not appear in combination with any of the following options:
settod.
</ul>
<div class="node">
<p><hr>
<a name="sntp-authentication"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-broadcast">sntp broadcast</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-adjtime">sntp adjtime</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>
<h4 class="subsection">authentication option (-a)</h4>
<p><a name="index-sntp_002dauthentication-5"></a>
This is the &ldquo;enable authentication with the key auth-keynumber&rdquo; option.
This option enables authentication using the key specified in this option's argument.
The argument of this option is the keyid, a number specified in the keyfile as this
key's identifier. See the keyfile option (-k) for more details.
<div class="node">
<p><hr>
<a name="sntp-broadcast"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-ipv4">sntp ipv4</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-authentication">sntp authentication</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>
<h4 class="subsection">broadcast option (-b)</h4>
<p><a name="index-sntp_002dbroadcast-6"></a>
This is the &ldquo;use broadcasts to the address specified for synchronisation&rdquo; option.
If specified SNTP will listen to the specified broadcast address
for NTP broadcasts. The default maximum wait time,
68 seconds, can be modified with -t.
<div class="node">
<p><hr>
<a name="sntp-ipv4"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-ipv6">sntp ipv6</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-broadcast">sntp broadcast</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>
<h4 class="subsection">ipv4 option (-4)</h4>
<p><a name="index-sntp_002dipv4-7"></a>
This is the &ldquo;force ipv4 dns name resolution&rdquo; option.
<p>This option has some usage constraints. It:
<ul>
<li>must not appear in combination with any of the following options:
ipv6.
</ul>
<p>Force DNS resolution of the following host names on the command line
to the IPv4 namespace.
<div class="node">
<p><hr>
<a name="sntp-ipv6"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-keyfile">sntp keyfile</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-ipv4">sntp ipv4</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>
<h4 class="subsection">ipv6 option (-6)</h4>
<p><a name="index-sntp_002dipv6-8"></a>
This is the &ldquo;force ipv6 dns name resolution&rdquo; option.
<p>This option has some usage constraints. It:
<ul>
<li>must not appear in combination with any of the following options:
ipv4.
</ul>
<p>Force DNS resolution of the following host names on the command line
to the IPv6 namespace.
<div class="node">
<p><hr>
<a name="sntp-keyfile"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-kod">sntp kod</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-ipv6">sntp ipv6</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>
<h4 class="subsection">keyfile option (-k)</h4>
<p><a name="index-sntp_002dkeyfile-9"></a>
This is the &ldquo;specify a keyfile. sntp will look in this file for the key specified with -a&rdquo; option.
This option specifies the keyfile. SNTP will search for the key specified with -a keyno in this
file. Key files follow the following format:
<p>keyid keytype key
<p>Where keyid is a number identifying this key
keytype is one of the follow:
S Key in 64 Bit hexadecimal number as specified in in the DES specification.
N Key in 64 Bit hexadecimal number as specified in the NTP standard.
A Key in a 1-to-8 character ASCII string.
M Key in a 1-to-8 character ASCII string using the MD5 authentication scheme.
<p>For more information see ntp.keys(5).
<div class="node">
<p><hr>
<a name="sntp-kod"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-logfile">sntp logfile</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-keyfile">sntp keyfile</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>
<h4 class="subsection">kod option (-K)</h4>
<p><a name="index-sntp_002dkod-10"></a>
This is the &ldquo;kod history filename&rdquo; option.
Specifies the filename to be used to persist the history of KoD
responses received from servers. The default is
/var/db/ntp-kod.
<div class="node">
<p><hr>
<a name="sntp-logfile"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-normalverbose">sntp normalverbose</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-kod">sntp kod</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>
<h4 class="subsection">logfile option (-l)</h4>
<p><a name="index-sntp_002dlogfile-11"></a>
This is the &ldquo;log to specified logfile&rdquo; option.
<p>This option has some usage constraints. It:
<ul>
<li>must not appear in combination with any of the following options:
syslog.
</ul>
<p>This option causes the client to write log messages to the specified
logfile.
<div class="node">
<p><hr>
<a name="sntp-normalverbose"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-settod">sntp settod</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-logfile">sntp logfile</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>
<h4 class="subsection">normalverbose option (-d)</h4>
<p><a name="index-sntp_002dnormalverbose-12"></a>
This is the &ldquo;normal verbose&rdquo; option.
Diagnostic messages for non-fatal errors and a limited amount of
tracing should be written to standard error. Fatal ones always
produce a diagnostic. This option should be set when there is a
suspected problem with the server, network or the source.
<div class="node">
<p><hr>
<a name="sntp-settod"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-syslog">sntp syslog</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-normalverbose">sntp normalverbose</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>
<h4 class="subsection">settod option (-s)</h4>
<p><a name="index-sntp_002dsettod-13"></a>
This is the &ldquo;set (step) the time with settimeofday()&rdquo; option.
<p>This option has some usage constraints. It:
<ul>
<li>must not appear in combination with any of the following options:
adjtime.
</ul>
<div class="node">
<p><hr>
<a name="sntp-syslog"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#sntp-timeout">sntp timeout</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-settod">sntp settod</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>
<h4 class="subsection">syslog option (-p)</h4>
<p><a name="index-sntp_002dsyslog-14"></a>
This is the &ldquo;logging with syslog&rdquo; option.
<p>This option has some usage constraints. It:
<ul>
<li>must not appear in combination with any of the following options:
logfile.
</ul>
<p>When this option is set all logging will be done using syslog.
<div class="node">
<p><hr>
<a name="sntp-timeout"></a>Previous:&nbsp;<a rel="previous" accesskey="p" href="#sntp-syslog">sntp syslog</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#sntp-Invocation">sntp Invocation</a>
<br>
</div>
<h4 class="subsection">timeout option (-t)</h4>
<p><a name="index-sntp_002dtimeout-15"></a>
This is the &ldquo;specify the number of seconds to wait for broadcasts&rdquo; option.
When waiting for a broadcast packet SNTP will wait the number
of seconds specified before giving up. Default 68 seconds.
<div class="node">
<p><hr>
<a name="Usage"></a>
<br>
</div>
<!-- node-name, next, previous, up -->
<h3 class="section">Usage</h3>
<p>The simplest use of this program is as an unprivileged command to
check the current time, offset, and error in the local clock.
For example:
<pre class="example"> sntp ntpserver.somewhere
</pre>
<p>With suitable privilege, it can be run as a command or in a
<code>crom</code> job to reset the local clock from a reliable server, like
the <code>ntpdate</code> and <code>rdate</code> commands.
For example:
<pre class="example"> sntp -a ntpserver.somewhere
</pre>
</body></html>