Home | History | Annotate | Line # | Download | only in ntpd
ntp.conf.def revision 1.1.1.12
      1 /* -*- Mode: Text -*- */
      2 
      3 autogen definitions options;
      4 
      5 #include copyright.def
      6 
      7 // We want the synopsis to be "/etc/ntp.conf" but we need the prog-name
      8 // to be ntp.conf - the latter is also how autogen produces the output
      9 // file name.
     10 prog-name	= "ntp.conf";
     11 file-path	= "/etc/ntp.conf";
     12 prog-title	= "Network Time Protocol (NTP) daemon configuration file format";
     13 
     14 /* explain: Additional information whenever the usage routine is invoked */
     15 explain = <<- _END_EXPLAIN
     16 	_END_EXPLAIN;
     17 
     18 doc-section	= {
     19   ds-type	= 'DESCRIPTION';
     20   ds-format	= 'mdoc';
     21   ds-text	= <<- _END_PROG_MDOC_DESCRIP
     22 The
     23 .Nm
     24 configuration file is read at initial startup by the
     25 .Xr ntpd 1ntpdmdoc
     26 daemon in order to specify the synchronization sources,
     27 modes and other related information.
     28 Usually, it is installed in the
     29 .Pa /etc
     30 directory,
     31 but could be installed elsewhere
     32 (see the daemon's
     33 .Fl c
     34 command line option).
     35 .Pp
     36 The file format is similar to other
     37 .Ux
     38 configuration files.
     39 Comments begin with a
     40 .Ql #
     41 character and extend to the end of the line;
     42 blank lines are ignored.
     43 Configuration commands consist of an initial keyword
     44 followed by a list of arguments,
     45 some of which may be optional, separated by whitespace.
     46 Commands may not be continued over multiple lines.
     47 Arguments may be host names,
     48 host addresses written in numeric, dotted-quad form,
     49 integers, floating point numbers (when specifying times in seconds)
     50 and text strings.
     51 .Pp
     52 The rest of this page describes the configuration and control options.
     53 The
     54 .Qq Notes on Configuring NTP and Setting up an NTP Subnet
     55 page
     56 (available as part of the HTML documentation
     57 provided in
     58 .Pa /usr/share/doc/ntp )
     59 contains an extended discussion of these options.
     60 In addition to the discussion of general
     61 .Sx Configuration Options ,
     62 there are sections describing the following supported functionality
     63 and the options used to control it:
     64 .Bl -bullet -offset indent
     65 .It
     66 .Sx Authentication Support
     67 .It
     68 .Sx Monitoring Support
     69 .It
     70 .Sx Access Control Support
     71 .It
     72 .Sx Automatic NTP Configuration Options
     73 .It
     74 .Sx Reference Clock Support
     75 .It
     76 .Sx Miscellaneous Options
     77 .El
     78 .Pp
     79 Following these is a section describing
     80 .Sx Miscellaneous Options .
     81 While there is a rich set of options available,
     82 the only required option is one or more
     83 .Ic pool ,
     84 .Ic server ,
     85 .Ic peer ,
     86 .Ic broadcast
     87 or
     88 .Ic manycastclient
     89 commands.
     90 .Sh Configuration Support
     91 Following is a description of the configuration commands in
     92 NTPv4.
     93 These commands have the same basic functions as in NTPv3 and
     94 in some cases new functions and new arguments.
     95 There are two
     96 classes of commands, configuration commands that configure a
     97 persistent association with a remote server or peer or reference
     98 clock, and auxiliary commands that specify environmental variables
     99 that control various related operations.
    100 .Ss Configuration Commands
    101 The various modes are determined by the command keyword and the
    102 type of the required IP address.
    103 Addresses are classed by type as
    104 (s) a remote server or peer (IPv4 class A, B and C), (b) the
    105 broadcast address of a local interface, (m) a multicast address (IPv4
    106 class D), or (r) a reference clock address (127.127.x.x).
    107 Note that
    108 only those options applicable to each command are listed below.
    109 Use
    110 of options not listed may not be caught as an error, but may result
    111 in some weird and even destructive behavior.
    112 .Pp
    113 If the Basic Socket Interface Extensions for IPv6 (RFC-2553)
    114 is detected, support for the IPv6 address family is generated
    115 in addition to the default support of the IPv4 address family.
    116 In a few cases, including the
    117 .Cm reslist
    118 billboard generated
    119 by
    120 .Xr ntpq 1ntpqmdoc
    121 or
    122 .Xr ntpdc 1ntpdcmdoc ,
    123 IPv6 addresses are automatically generated.
    124 IPv6 addresses can be identified by the presence of colons
    125 .Dq \&:
    126 in the address field.
    127 IPv6 addresses can be used almost everywhere where
    128 IPv4 addresses can be used,
    129 with the exception of reference clock addresses,
    130 which are always IPv4.
    131 .Pp
    132 Note that in contexts where a host name is expected, a
    133 .Fl 4
    134 qualifier preceding
    135 the host name forces DNS resolution to the IPv4 namespace,
    136 while a
    137 .Fl 6
    138 qualifier forces DNS resolution to the IPv6 namespace.
    139 See IPv6 references for the
    140 equivalent classes for that address family.
    141 .Bl -tag -width indent
    142 .It Xo Ic pool Ar address
    143 .Op Cm burst
    144 .Op Cm iburst
    145 .Op Cm version Ar version
    146 .Op Cm prefer
    147 .Op Cm minpoll Ar minpoll
    148 .Op Cm maxpoll Ar maxpoll
    149 .Op Cm xmtnonce
    150 .Xc
    151 .It Xo Ic server Ar address
    152 .Op Cm key Ar key \&| Cm autokey
    153 .Op Cm burst
    154 .Op Cm iburst
    155 .Op Cm version Ar version
    156 .Op Cm prefer
    157 .Op Cm minpoll Ar minpoll
    158 .Op Cm maxpoll Ar maxpoll
    159 .Op Cm true
    160 .Op Cm xmtnonce
    161 .Xc
    162 .It Xo Ic peer Ar address
    163 .Op Cm key Ar key \&| Cm autokey
    164 .Op Cm version Ar version
    165 .Op Cm prefer
    166 .Op Cm minpoll Ar minpoll
    167 .Op Cm maxpoll Ar maxpoll
    168 .Op Cm true
    169 .Op Cm xleave
    170 .Xc
    171 .It Xo Ic broadcast Ar address
    172 .Op Cm key Ar key \&| Cm autokey
    173 .Op Cm version Ar version
    174 .Op Cm prefer
    175 .Op Cm minpoll Ar minpoll
    176 .Op Cm ttl Ar ttl
    177 .Op Cm xleave
    178 .Xc
    179 .It Xo Ic manycastclient Ar address
    180 .Op Cm key Ar key \&| Cm autokey
    181 .Op Cm version Ar version
    182 .Op Cm prefer
    183 .Op Cm minpoll Ar minpoll
    184 .Op Cm maxpoll Ar maxpoll
    185 .Op Cm ttl Ar ttl
    186 .Xc
    187 .El
    188 .Pp
    189 These five commands specify the time server name or address to
    190 be used and the mode in which to operate.
    191 The
    192 .Ar address
    193 can be
    194 either a DNS name or an IP address in dotted-quad notation.
    195 Additional information on association behavior can be found in the
    196 .Qq Association Management
    197 page
    198 (available as part of the HTML documentation
    199 provided in
    200 .Pa /usr/share/doc/ntp ) .
    201 .Bl -tag -width indent
    202 .It Ic pool
    203 For type s addresses, this command mobilizes a persistent
    204 client mode association with a number of remote servers.
    205 In this mode the local clock can synchronized to the
    206 remote server, but the remote server can never be synchronized to
    207 the local clock.
    208 .It Ic server
    209 For type s and r addresses, this command mobilizes a persistent
    210 client mode association with the specified remote server or local
    211 radio clock.
    212 In this mode the local clock can synchronized to the
    213 remote server, but the remote server can never be synchronized to
    214 the local clock.
    215 This command should
    216 .Em not
    217 be used for type
    218 b or m addresses.
    219 .It Ic peer
    220 For type s addresses (only), this command mobilizes a
    221 persistent symmetric-active mode association with the specified
    222 remote peer.
    223 In this mode the local clock can be synchronized to
    224 the remote peer or the remote peer can be synchronized to the local
    225 clock.
    226 This is useful in a network of servers where, depending on
    227 various failure scenarios, either the local or remote peer may be
    228 the better source of time.
    229 This command should NOT be used for type
    230 b, m or r addresses.
    231 .It Ic broadcast
    232 For type b and m addresses (only), this
    233 command mobilizes a persistent broadcast mode association.
    234 Multiple
    235 commands can be used to specify multiple local broadcast interfaces
    236 (subnets) and/or multiple multicast groups.
    237 Note that local
    238 broadcast messages go only to the interface associated with the
    239 subnet specified, but multicast messages go to all interfaces.
    240 In broadcast mode the local server sends periodic broadcast
    241 messages to a client population at the
    242 .Ar address
    243 specified, which is usually the broadcast address on (one of) the
    244 local network(s) or a multicast address assigned to NTP.
    245 The IANA
    246 has assigned the multicast group address IPv4 224.0.1.1 and
    247 IPv6 ff05::101 (site local) exclusively to
    248 NTP, but other nonconflicting addresses can be used to contain the
    249 messages within administrative boundaries.
    250 Ordinarily, this
    251 specification applies only to the local server operating as a
    252 sender; for operation as a broadcast client, see the
    253 .Ic broadcastclient
    254 or
    255 .Ic multicastclient
    256 commands
    257 below.
    258 .It Ic manycastclient
    259 For type m addresses (only), this command mobilizes a
    260 manycast client mode association for the multicast address
    261 specified.
    262 In this case a specific address must be supplied which
    263 matches the address used on the
    264 .Ic manycastserver
    265 command for
    266 the designated manycast servers.
    267 The NTP multicast address
    268 224.0.1.1 assigned by the IANA should NOT be used, unless specific
    269 means are taken to avoid spraying large areas of the Internet with
    270 these messages and causing a possibly massive implosion of replies
    271 at the sender.
    272 The
    273 .Ic manycastserver
    274 command specifies that the local server
    275 is to operate in client mode with the remote servers that are
    276 discovered as the result of broadcast/multicast messages.
    277 The
    278 client broadcasts a request message to the group address associated
    279 with the specified
    280 .Ar address
    281 and specifically enabled
    282 servers respond to these messages.
    283 The client selects the servers
    284 providing the best time and continues as with the
    285 .Ic server
    286 command.
    287 The remaining servers are discarded as if never
    288 heard.
    289 .El
    290 .Pp
    291 Options:
    292 .Bl -tag -width indent
    293 .It Cm autokey
    294 All packets sent to and received from the server or peer are to
    295 include authentication fields encrypted using the autokey scheme
    296 described in
    297 .Sx Authentication Options .
    298 .It Cm burst
    299 when the server is reachable, send a burst of six packets
    300 instead of the usual one. The packet spacing is 2 s.
    301 This is designed to improve timekeeping quality with the
    302 .Ic server
    303 command and s addresses.
    304 .It Cm iburst
    305 When the server is unreachable, send a burst of eight packets
    306 instead of the usual one.
    307 The packet spacing is 2 s.
    308 This is designed to speed the initial synchronization
    309 acquisition with the
    310 .Ic server
    311 command and s addresses and when
    312 .Xr ntpd 1ntpdmdoc
    313 is started with the
    314 .Fl q
    315 option.
    316 .It Cm key Ar key
    317 All packets sent to and received from the server or peer are to
    318 include authentication fields encrypted using the specified
    319 .Ar key
    320 identifier with values from 1 to 65535, inclusive.
    321 The
    322 default is to include no encryption field.
    323 .It Cm minpoll Ar minpoll
    324 .It Cm maxpoll Ar maxpoll
    325 These options specify the minimum and maximum poll intervals
    326 for NTP messages, as a power of 2 in seconds
    327 The maximum poll
    328 interval defaults to 10 (1,024 s), but can be increased by the
    329 .Cm maxpoll
    330 option to an upper limit of 17 (36.4 h).
    331 The
    332 minimum poll interval defaults to 6 (64 s), but can be decreased by
    333 the
    334 .Cm minpoll
    335 option to a lower limit of 4 (16 s).
    336 .It Cm noselect
    337 Marks the server as unused, except for display purposes.
    338 The server is discarded by the selection algroithm.
    339 .It Cm preempt
    340 Says the association can be preempted.
    341 .It Cm prefer
    342 Marks the server as preferred.
    343 All other things being equal,
    344 this host will be chosen for synchronization among a set of
    345 correctly operating hosts.
    346 See the
    347 .Qq Mitigation Rules and the prefer Keyword
    348 page
    349 (available as part of the HTML documentation
    350 provided in
    351 .Pa /usr/share/doc/ntp )
    352 for further information.
    353 .It Cm true
    354 Marks the server as a truechimer,
    355 forcing the association to always survive the selection and clustering algorithms.
    356 This option should almost certainly
    357 .Em only
    358 be used while testing an association.
    359 .It Cm ttl Ar ttl
    360 This option is used only with broadcast server and manycast
    361 client modes.
    362 It specifies the time-to-live
    363 .Ar ttl
    364 to
    365 use on broadcast server and multicast server and the maximum
    366 .Ar ttl
    367 for the expanding ring search with manycast
    368 client packets.
    369 Selection of the proper value, which defaults to
    370 127, is something of a black art and should be coordinated with the
    371 network administrator.
    372 .It Cm version Ar version
    373 Specifies the version number to be used for outgoing NTP
    374 packets.
    375 Versions 1-4 are the choices, with version 4 the
    376 default.
    377 .It Cm xleave
    378 Valid in
    379 .Cm peer
    380 and
    381 .Cm broadcast
    382 modes only, this flag enables interleave mode.
    383 .It Cm xmtnonce
    384 Valid only for
    385 .Cm server
    386 and
    387 .Cm pool
    388 modes, this flag puts a random number in the packet's transmit timestamp.
    389 
    390 .El
    391 .Ss Auxiliary Commands
    392 .Bl -tag -width indent
    393 .It Ic broadcastclient
    394 This command enables reception of broadcast server messages to
    395 any local interface (type b) address.
    396 Upon receiving a message for
    397 the first time, the broadcast client measures the nominal server
    398 propagation delay using a brief client/server exchange with the
    399 server, then enters the broadcast client mode, in which it
    400 synchronizes to succeeding broadcast messages.
    401 Note that, in order
    402 to avoid accidental or malicious disruption in this mode, both the
    403 server and client should operate using symmetric-key or public-key
    404 authentication as described in
    405 .Sx Authentication Options .
    406 .It Ic manycastserver Ar address ...
    407 This command enables reception of manycast client messages to
    408 the multicast group address(es) (type m) specified.
    409 At least one
    410 address is required, but the NTP multicast address 224.0.1.1
    411 assigned by the IANA should NOT be used, unless specific means are
    412 taken to limit the span of the reply and avoid a possibly massive
    413 implosion at the original sender.
    414 Note that, in order to avoid
    415 accidental or malicious disruption in this mode, both the server
    416 and client should operate using symmetric-key or public-key
    417 authentication as described in
    418 .Sx Authentication Options .
    419 .It Ic multicastclient Ar address ...
    420 This command enables reception of multicast server messages to
    421 the multicast group address(es) (type m) specified.
    422 Upon receiving
    423 a message for the first time, the multicast client measures the
    424 nominal server propagation delay using a brief client/server
    425 exchange with the server, then enters the broadcast client mode, in
    426 which it synchronizes to succeeding multicast messages.
    427 Note that,
    428 in order to avoid accidental or malicious disruption in this mode,
    429 both the server and client should operate using symmetric-key or
    430 public-key authentication as described in
    431 .Sx Authentication Options .
    432 .It Ic mdnstries Ar number
    433 If we are participating in mDNS,
    434 after we have synched for the first time
    435 we attempt to register with the mDNS system.
    436 If that registration attempt fails,
    437 we try again at one minute intervals for up to
    438 .Ic mdnstries
    439 times.
    440 After all,
    441 .Ic ntpd
    442 may be starting before mDNS.
    443 The default value for
    444 .Ic mdnstries
    445 is 5.
    446 .El
    447 .Sh Authentication Support
    448 Authentication support allows the NTP client to verify that the
    449 server is in fact known and trusted and not an intruder intending
    450 accidentally or on purpose to masquerade as that server.
    451 The NTPv3
    452 specification RFC-1305 defines a scheme which provides
    453 cryptographic authentication of received NTP packets.
    454 Originally,
    455 this was done using the Data Encryption Standard (DES) algorithm
    456 operating in Cipher Block Chaining (CBC) mode, commonly called
    457 DES-CBC.
    458 Subsequently, this was replaced by the RSA Message Digest
    459 5 (MD5) algorithm using a private key, commonly called keyed-MD5.
    460 Either algorithm computes a message digest, or one-way hash, which
    461 can be used to verify the server has the correct private key and
    462 key identifier.
    463 .Pp
    464 NTPv4 retains the NTPv3 scheme, properly described as symmetric key
    465 cryptography and, in addition, provides a new Autokey scheme
    466 based on public key cryptography.
    467 Public key cryptography is generally considered more secure
    468 than symmetric key cryptography, since the security is based
    469 on a private value which is generated by each server and
    470 never revealed.
    471 With Autokey all key distribution and
    472 management functions involve only public values, which
    473 considerably simplifies key distribution and storage.
    474 Public key management is based on X.509 certificates,
    475 which can be provided by commercial services or
    476 produced by utility programs in the OpenSSL software library
    477 or the NTPv4 distribution.
    478 .Pp
    479 While the algorithms for symmetric key cryptography are
    480 included in the NTPv4 distribution, public key cryptography
    481 requires the OpenSSL software library to be installed
    482 before building the NTP distribution.
    483 Directions for doing that
    484 are on the Building and Installing the Distribution page.
    485 .Pp
    486 Authentication is configured separately for each association
    487 using the
    488 .Cm key
    489 or
    490 .Cm autokey
    491 subcommand on the
    492 .Ic peer ,
    493 .Ic server ,
    494 .Ic broadcast
    495 and
    496 .Ic manycastclient
    497 configuration commands as described in
    498 .Sx Configuration Options
    499 page.
    500 The authentication
    501 options described below specify the locations of the key files,
    502 if other than default, which symmetric keys are trusted
    503 and the interval between various operations, if other than default.
    504 .Pp
    505 Authentication is always enabled,
    506 although ineffective if not configured as
    507 described below.
    508 If a NTP packet arrives
    509 including a message authentication
    510 code (MAC), it is accepted only if it
    511 passes all cryptographic checks.
    512 The
    513 checks require correct key ID, key value
    514 and message digest.
    515 If the packet has
    516 been modified in any way or replayed
    517 by an intruder, it will fail one or more
    518 of these checks and be discarded.
    519 Furthermore, the Autokey scheme requires a
    520 preliminary protocol exchange to obtain
    521 the server certificate, verify its
    522 credentials and initialize the protocol
    523 .Pp
    524 The
    525 .Cm auth
    526 flag controls whether new associations or
    527 remote configuration commands require cryptographic authentication.
    528 This flag can be set or reset by the
    529 .Ic enable
    530 and
    531 .Ic disable
    532 commands and also by remote
    533 configuration commands sent by a
    534 .Xr ntpdc 1ntpdcmdoc
    535 program running on
    536 another machine.
    537 If this flag is enabled, which is the default
    538 case, new broadcast client and symmetric passive associations and
    539 remote configuration commands must be cryptographically
    540 authenticated using either symmetric key or public key cryptography.
    541 If this
    542 flag is disabled, these operations are effective
    543 even if not cryptographic
    544 authenticated.
    545 It should be understood
    546 that operating with the
    547 .Ic auth
    548 flag disabled invites a significant vulnerability
    549 where a rogue hacker can
    550 masquerade as a falseticker and seriously
    551 disrupt system timekeeping.
    552 It is
    553 important to note that this flag has no purpose
    554 other than to allow or disallow
    555 a new association in response to new broadcast
    556 and symmetric active messages
    557 and remote configuration commands and, in particular,
    558 the flag has no effect on
    559 the authentication process itself.
    560 .Pp
    561 An attractive alternative where multicast support is available
    562 is manycast mode, in which clients periodically troll
    563 for servers as described in the
    564 .Sx Automatic NTP Configuration Options
    565 page.
    566 Either symmetric key or public key
    567 cryptographic authentication can be used in this mode.
    568 The principle advantage
    569 of manycast mode is that potential servers need not be
    570 configured in advance,
    571 since the client finds them during regular operation,
    572 and the configuration
    573 files for all clients can be identical.
    574 .Pp
    575 The security model and protocol schemes for
    576 both symmetric key and public key
    577 cryptography are summarized below;
    578 further details are in the briefings, papers
    579 and reports at the NTP project page linked from
    580 .Li http://www.ntp.org/ .
    581 .Ss Symmetric-Key Cryptography
    582 The original RFC-1305 specification allows any one of possibly
    583 65,535 keys, each distinguished by a 32-bit key identifier, to
    584 authenticate an association.
    585 The servers and clients involved must
    586 agree on the key and key identifier to
    587 authenticate NTP packets.
    588 Keys and
    589 related information are specified in a key
    590 file, usually called
    591 .Pa ntp.keys ,
    592 which must be distributed and stored using
    593 secure means beyond the scope of the NTP protocol itself.
    594 Besides the keys used
    595 for ordinary NTP associations,
    596 additional keys can be used as passwords for the
    597 .Xr ntpq 1ntpqmdoc
    598 and
    599 .Xr ntpdc 1ntpdcmdoc
    600 utility programs.
    601 .Pp
    602 When
    603 .Xr ntpd 1ntpdmdoc
    604 is first started, it reads the key file specified in the
    605 .Ic keys
    606 configuration command and installs the keys
    607 in the key cache.
    608 However,
    609 individual keys must be activated with the
    610 .Ic trusted
    611 command before use.
    612 This
    613 allows, for instance, the installation of possibly
    614 several batches of keys and
    615 then activating or deactivating each batch
    616 remotely using
    617 .Xr ntpdc 1ntpdcmdoc .
    618 This also provides a revocation capability that can be used
    619 if a key becomes compromised.
    620 The
    621 .Ic requestkey
    622 command selects the key used as the password for the
    623 .Xr ntpdc 1ntpdcmdoc
    624 utility, while the
    625 .Ic controlkey
    626 command selects the key used as the password for the
    627 .Xr ntpq 1ntpqmdoc
    628 utility.
    629 .Ss Public Key Cryptography
    630 NTPv4 supports the original NTPv3 symmetric key scheme
    631 described in RFC-1305 and in addition the Autokey protocol,
    632 which is based on public key cryptography.
    633 The Autokey Version 2 protocol described on the Autokey Protocol
    634 page verifies packet integrity using MD5 message digests
    635 and verifies the source with digital signatures and any of several
    636 digest/signature schemes.
    637 Optional identity schemes described on the Identity Schemes
    638 page and based on cryptographic challenge/response algorithms
    639 are also available.
    640 Using all of these schemes provides strong security against
    641 replay with or without modification, spoofing, masquerade
    642 and most forms of clogging attacks.
    643 .\" .Pp
    644 .\" The cryptographic means necessary for all Autokey operations
    645 .\" is provided by the OpenSSL software library.
    646 .\" This library is available from http://www.openssl.org/
    647 .\" and can be installed using the procedures outlined
    648 .\" in the Building and Installing the Distribution page.
    649 .\" Once installed,
    650 .\" the configure and build
    651 .\" process automatically detects the library and links
    652 .\" the library routines required.
    653 .Pp
    654 The Autokey protocol has several modes of operation
    655 corresponding to the various NTP modes supported.
    656 Most modes use a special cookie which can be
    657 computed independently by the client and server,
    658 but encrypted in transmission.
    659 All modes use in addition a variant of the S-KEY scheme,
    660 in which a pseudo-random key list is generated and used
    661 in reverse order.
    662 These schemes are described along with an executive summary,
    663 current status, briefing slides and reading list on the
    664 .Sx Autonomous Authentication
    665 page.
    666 .Pp
    667 The specific cryptographic environment used by Autokey servers
    668 and clients is determined by a set of files
    669 and soft links generated by the
    670 .Xr ntp-keygen 1ntpkeygenmdoc
    671 program.
    672 This includes a required host key file,
    673 required certificate file and optional sign key file,
    674 leapsecond file and identity scheme files.
    675 The
    676 digest/signature scheme is specified in the X.509 certificate
    677 along with the matching sign key.
    678 There are several schemes
    679 available in the OpenSSL software library, each identified
    680 by a specific string such as
    681 .Cm md5WithRSAEncryption ,
    682 which stands for the MD5 message digest with RSA
    683 encryption scheme.
    684 The current NTP distribution supports
    685 all the schemes in the OpenSSL library, including
    686 those based on RSA and DSA digital signatures.
    687 .Pp
    688 NTP secure groups can be used to define cryptographic compartments
    689 and security hierarchies.
    690 It is important that every host
    691 in the group be able to construct a certificate trail to one
    692 or more trusted hosts in the same group.
    693 Each group
    694 host runs the Autokey protocol to obtain the certificates
    695 for all hosts along the trail to one or more trusted hosts.
    696 This requires the configuration file in all hosts to be
    697 engineered so that, even under anticipated failure conditions,
    698 the NTP subnet will form such that every group host can find
    699 a trail to at least one trusted host.
    700 .Ss Naming and Addressing
    701 It is important to note that Autokey does not use DNS to
    702 resolve addresses, since DNS can't be completely trusted
    703 until the name servers have synchronized clocks.
    704 The cryptographic name used by Autokey to bind the host identity
    705 credentials and cryptographic values must be independent
    706 of interface, network and any other naming convention.
    707 The name appears in the host certificate in either or both
    708 the subject and issuer fields, so protection against
    709 DNS compromise is essential.
    710 .Pp
    711 By convention, the name of an Autokey host is the name returned
    712 by the Unix
    713 .Xr gethostname 2
    714 system call or equivalent in other systems.
    715 By the system design
    716 model, there are no provisions to allow alternate names or aliases.
    717 However, this is not to say that DNS aliases, different names
    718 for each interface, etc., are constrained in any way.
    719 .Pp
    720 It is also important to note that Autokey verifies authenticity
    721 using the host name, network address and public keys,
    722 all of which are bound together by the protocol specifically
    723 to deflect masquerade attacks.
    724 For this reason Autokey
    725 includes the source and destination IP addresses in message digest
    726 computations and so the same addresses must be available
    727 at both the server and client.
    728 For this reason operation
    729 with network address translation schemes is not possible.
    730 This reflects the intended robust security model where government
    731 and corporate NTP servers are operated outside firewall perimeters.
    732 .Ss Operation
    733 A specific combination of authentication scheme (none,
    734 symmetric key, public key) and identity scheme is called
    735 a cryptotype, although not all combinations are compatible.
    736 There may be management configurations where the clients,
    737 servers and peers may not all support the same cryptotypes.
    738 A secure NTPv4 subnet can be configured in many ways while
    739 keeping in mind the principles explained above and
    740 in this section.
    741 Note however that some cryptotype
    742 combinations may successfully interoperate with each other,
    743 but may not represent good security practice.
    744 .Pp
    745 The cryptotype of an association is determined at the time
    746 of mobilization, either at configuration time or some time
    747 later when a message of appropriate cryptotype arrives.
    748 When mobilized by a
    749 .Ic server
    750 or
    751 .Ic peer
    752 configuration command and no
    753 .Ic key
    754 or
    755 .Ic autokey
    756 subcommands are present, the association is not
    757 authenticated; if the
    758 .Ic key
    759 subcommand is present, the association is authenticated
    760 using the symmetric key ID specified; if the
    761 .Ic autokey
    762 subcommand is present, the association is authenticated
    763 using Autokey.
    764 .Pp
    765 When multiple identity schemes are supported in the Autokey
    766 protocol, the first message exchange determines which one is used.
    767 The client request message contains bits corresponding
    768 to which schemes it has available.
    769 The server response message
    770 contains bits corresponding to which schemes it has available.
    771 Both server and client match the received bits with their own
    772 and select a common scheme.
    773 .Pp
    774 Following the principle that time is a public value,
    775 a server responds to any client packet that matches
    776 its cryptotype capabilities.
    777 Thus, a server receiving
    778 an unauthenticated packet will respond with an unauthenticated
    779 packet, while the same server receiving a packet of a cryptotype
    780 it supports will respond with packets of that cryptotype.
    781 However, unconfigured broadcast or manycast client
    782 associations or symmetric passive associations will not be
    783 mobilized unless the server supports a cryptotype compatible
    784 with the first packet received.
    785 By default, unauthenticated associations will not be mobilized
    786 unless overridden in a decidedly dangerous way.
    787 .Pp
    788 Some examples may help to reduce confusion.
    789 Client Alice has no specific cryptotype selected.
    790 Server Bob has both a symmetric key file and minimal Autokey files.
    791 Alice's unauthenticated messages arrive at Bob, who replies with
    792 unauthenticated messages.
    793 Cathy has a copy of Bob's symmetric
    794 key file and has selected key ID 4 in messages to Bob.
    795 Bob verifies the message with his key ID 4.
    796 If it's the
    797 same key and the message is verified, Bob sends Cathy a reply
    798 authenticated with that key.
    799 If verification fails,
    800 Bob sends Cathy a thing called a crypto-NAK, which tells her
    801 something broke.
    802 She can see the evidence using the
    803 .Xr ntpq 1ntpqmdoc
    804 program.
    805 .Pp
    806 Denise has rolled her own host key and certificate.
    807 She also uses one of the identity schemes as Bob.
    808 She sends the first Autokey message to Bob and they
    809 both dance the protocol authentication and identity steps.
    810 If all comes out okay, Denise and Bob continue as described above.
    811 .Pp
    812 It should be clear from the above that Bob can support
    813 all the girls at the same time, as long as he has compatible
    814 authentication and identity credentials.
    815 Now, Bob can act just like the girls in his own choice of servers;
    816 he can run multiple configured associations with multiple different
    817 servers (or the same server, although that might not be useful).
    818 But, wise security policy might preclude some cryptotype
    819 combinations; for instance, running an identity scheme
    820 with one server and no authentication with another might not be wise.
    821 .Ss Key Management
    822 The cryptographic values used by the Autokey protocol are
    823 incorporated as a set of files generated by the
    824 .Xr ntp-keygen 1ntpkeygenmdoc
    825 utility program, including symmetric key, host key and
    826 public certificate files, as well as sign key, identity parameters
    827 and leapseconds files.
    828 Alternatively, host and sign keys and
    829 certificate files can be generated by the OpenSSL utilities
    830 and certificates can be imported from public certificate
    831 authorities.
    832 Note that symmetric keys are necessary for the
    833 .Xr ntpq 1ntpqmdoc
    834 and
    835 .Xr ntpdc 1ntpdcmdoc
    836 utility programs.
    837 The remaining files are necessary only for the
    838 Autokey protocol.
    839 .Pp
    840 Certificates imported from OpenSSL or public certificate
    841 authorities have certian limitations.
    842 The certificate should be in ASN.1 syntax, X.509 Version 3
    843 format and encoded in PEM, which is the same format
    844 used by OpenSSL.
    845 The overall length of the certificate encoded
    846 in ASN.1 must not exceed 1024 bytes.
    847 The subject distinguished
    848 name field (CN) is the fully qualified name of the host
    849 on which it is used; the remaining subject fields are ignored.
    850 The certificate extension fields must not contain either
    851 a subject key identifier or a issuer key identifier field;
    852 however, an extended key usage field for a trusted host must
    853 contain the value
    854 .Cm trustRoot ; .
    855 Other extension fields are ignored.
    856 .Ss Authentication Commands
    857 .Bl -tag -width indent
    858 .It Ic autokey Op Ar logsec
    859 Specifies the interval between regenerations of the session key
    860 list used with the Autokey protocol.
    861 Note that the size of the key
    862 list for each association depends on this interval and the current
    863 poll interval.
    864 The default value is 12 (4096 s or about 1.1 hours).
    865 For poll intervals above the specified interval, a session key list
    866 with a single entry will be regenerated for every message
    867 sent.
    868 .It Ic controlkey Ar key
    869 Specifies the key identifier to use with the
    870 .Xr ntpq 1ntpqmdoc
    871 utility, which uses the standard
    872 protocol defined in RFC-1305.
    873 The
    874 .Ar key
    875 argument is
    876 the key identifier for a trusted key, where the value can be in the
    877 range 1 to 65,535, inclusive.
    878 .It Xo Ic crypto
    879 .Op Cm cert Ar file
    880 .Op Cm leap Ar file
    881 .Op Cm randfile Ar file
    882 .Op Cm host Ar file
    883 .Op Cm gq Ar file
    884 .Op Cm gqpar Ar file
    885 .Op Cm iffpar Ar file
    886 .Op Cm mvpar Ar file
    887 .Op Cm pw Ar password
    888 .Xc
    889 This command requires the OpenSSL library.
    890 It activates public key
    891 cryptography, selects the message digest and signature
    892 encryption scheme and loads the required private and public
    893 values described above.
    894 If one or more files are left unspecified,
    895 the default names are used as described above.
    896 Unless the complete path and name of the file are specified, the
    897 location of a file is relative to the keys directory specified
    898 in the
    899 .Ic keysdir
    900 command or default
    901 .Pa /usr/local/etc .
    902 Following are the subcommands:
    903 .Bl -tag -width indent
    904 .It Cm cert Ar file
    905 Specifies the location of the required host public certificate file.
    906 This overrides the link
    907 .Pa ntpkey_cert_ Ns Ar hostname
    908 in the keys directory.
    909 .It Cm gqpar Ar file
    910 Specifies the location of the optional GQ parameters file.
    911 This
    912 overrides the link
    913 .Pa ntpkey_gq_ Ns Ar hostname
    914 in the keys directory.
    915 .It Cm host Ar file
    916 Specifies the location of the required host key file.
    917 This overrides
    918 the link
    919 .Pa ntpkey_key_ Ns Ar hostname
    920 in the keys directory.
    921 .It Cm iffpar Ar file
    922 Specifies the location of the optional IFF parameters file.
    923 This overrides the link
    924 .Pa ntpkey_iff_ Ns Ar hostname
    925 in the keys directory.
    926 .It Cm leap Ar file
    927 Specifies the location of the optional leapsecond file.
    928 This overrides the link
    929 .Pa ntpkey_leap
    930 in the keys directory.
    931 .It Cm mvpar Ar file
    932 Specifies the location of the optional MV parameters file.
    933 This overrides the link
    934 .Pa ntpkey_mv_ Ns Ar hostname
    935 in the keys directory.
    936 .It Cm pw Ar password
    937 Specifies the password to decrypt files containing private keys and
    938 identity parameters.
    939 This is required only if these files have been
    940 encrypted.
    941 .It Cm randfile Ar file
    942 Specifies the location of the random seed file used by the OpenSSL
    943 library.
    944 The defaults are described in the main text above.
    945 .El
    946 .It Ic keys Ar keyfile
    947 Specifies the complete path and location of the MD5 key file
    948 containing the keys and key identifiers used by
    949 .Xr ntpd 1ntpdmdoc ,
    950 .Xr ntpq 1ntpqmdoc
    951 and
    952 .Xr ntpdc 1ntpdcmdoc
    953 when operating with symmetric key cryptography.
    954 This is the same operation as the
    955 .Fl k
    956 command line option.
    957 .It Ic keysdir Ar path
    958 This command specifies the default directory path for
    959 cryptographic keys, parameters and certificates.
    960 The default is
    961 .Pa /usr/local/etc/ .
    962 .It Ic requestkey Ar key
    963 Specifies the key identifier to use with the
    964 .Xr ntpdc 1ntpdcmdoc
    965 utility program, which uses a
    966 proprietary protocol specific to this implementation of
    967 .Xr ntpd 1ntpdmdoc .
    968 The
    969 .Ar key
    970 argument is a key identifier
    971 for the trusted key, where the value can be in the range 1 to
    972 65,535, inclusive.
    973 .It Ic revoke Ar logsec
    974 Specifies the interval between re-randomization of certain
    975 cryptographic values used by the Autokey scheme, as a power of 2 in
    976 seconds.
    977 These values need to be updated frequently in order to
    978 deflect brute-force attacks on the algorithms of the scheme;
    979 however, updating some values is a relatively expensive operation.
    980 The default interval is 16 (65,536 s or about 18 hours).
    981 For poll
    982 intervals above the specified interval, the values will be updated
    983 for every message sent.
    984 .It Ic trustedkey Ar key ...
    985 Specifies the key identifiers which are trusted for the
    986 purposes of authenticating peers with symmetric key cryptography,
    987 as well as keys used by the
    988 .Xr ntpq 1ntpqmdoc
    989 and
    990 .Xr ntpdc 1ntpdcmdoc
    991 programs.
    992 The authentication procedures require that both the local
    993 and remote servers share the same key and key identifier for this
    994 purpose, although different keys can be used with different
    995 servers.
    996 The
    997 .Ar key
    998 arguments are 32-bit unsigned
    999 integers with values from 1 to 65,535.
   1000 .El
   1001 .Ss Error Codes
   1002 The following error codes are reported via the NTP control
   1003 and monitoring protocol trap mechanism.
   1004 .Bl -tag -width indent
   1005 .It 101
   1006 .Pq bad field format or length
   1007 The packet has invalid version, length or format.
   1008 .It 102
   1009 .Pq bad timestamp
   1010 The packet timestamp is the same or older than the most recent received.
   1011 This could be due to a replay or a server clock time step.
   1012 .It 103
   1013 .Pq bad filestamp
   1014 The packet filestamp is the same or older than the most recent received.
   1015 This could be due to a replay or a key file generation error.
   1016 .It 104
   1017 .Pq bad or missing public key
   1018 The public key is missing, has incorrect format or is an unsupported type.
   1019 .It 105
   1020 .Pq unsupported digest type
   1021 The server requires an unsupported digest/signature scheme.
   1022 .It 106
   1023 .Pq mismatched digest types
   1024 Not used.
   1025 .It 107
   1026 .Pq bad signature length
   1027 The signature length does not match the current public key.
   1028 .It 108
   1029 .Pq signature not verified
   1030 The message fails the signature check.
   1031 It could be bogus or signed by a
   1032 different private key.
   1033 .It 109
   1034 .Pq certificate not verified
   1035 The certificate is invalid or signed with the wrong key.
   1036 .It 110
   1037 .Pq certificate not verified
   1038 The certificate is not yet valid or has expired or the signature could not
   1039 be verified.
   1040 .It 111
   1041 .Pq bad or missing cookie
   1042 The cookie is missing, corrupted or bogus.
   1043 .It 112
   1044 .Pq bad or missing leapseconds table
   1045 The leapseconds table is missing, corrupted or bogus.
   1046 .It 113
   1047 .Pq bad or missing certificate
   1048 The certificate is missing, corrupted or bogus.
   1049 .It 114
   1050 .Pq bad or missing identity
   1051 The identity key is missing, corrupt or bogus.
   1052 .El
   1053 .Sh Monitoring Support
   1054 .Xr ntpd 1ntpdmdoc
   1055 includes a comprehensive monitoring facility suitable
   1056 for continuous, long term recording of server and client
   1057 timekeeping performance.
   1058 See the
   1059 .Ic statistics
   1060 command below
   1061 for a listing and example of each type of statistics currently
   1062 supported.
   1063 Statistic files are managed using file generation sets
   1064 and scripts in the
   1065 .Pa ./scripts
   1066 directory of the source code distribution.
   1067 Using
   1068 these facilities and
   1069 .Ux
   1070 .Xr cron 8
   1071 jobs, the data can be
   1072 automatically summarized and archived for retrospective analysis.
   1073 .Ss Monitoring Commands
   1074 .Bl -tag -width indent
   1075 .It Ic statistics Ar name ...
   1076 Enables writing of statistics records.
   1077 Currently, eight kinds of
   1078 .Ar name
   1079 statistics are supported.
   1080 .Bl -tag -width indent
   1081 .It Cm clockstats
   1082 Enables recording of clock driver statistics information.
   1083 Each update
   1084 received from a clock driver appends a line of the following form to
   1085 the file generation set named
   1086 .Cm clockstats :
   1087 .Bd -literal
   1088 49213 525.624 127.127.4.1 93 226 00:08:29.606 D
   1089 .Ed
   1090 .Pp
   1091 The first two fields show the date (Modified Julian Day) and time
   1092 (seconds and fraction past UTC midnight).
   1093 The next field shows the
   1094 clock address in dotted-quad notation.
   1095 The final field shows the last
   1096 timecode received from the clock in decoded ASCII format, where
   1097 meaningful.
   1098 In some clock drivers a good deal of additional information
   1099 can be gathered and displayed as well.
   1100 See information specific to each
   1101 clock for further details.
   1102 .It Cm cryptostats
   1103 This option requires the OpenSSL cryptographic software library.
   1104 It
   1105 enables recording of cryptographic public key protocol information.
   1106 Each message received by the protocol module appends a line of the
   1107 following form to the file generation set named
   1108 .Cm cryptostats :
   1109 .Bd -literal
   1110 49213 525.624 127.127.4.1 message
   1111 .Ed
   1112 .Pp
   1113 The first two fields show the date (Modified Julian Day) and time
   1114 (seconds and fraction past UTC midnight).
   1115 The next field shows the peer
   1116 address in dotted-quad notation, The final message field includes the
   1117 message type and certain ancillary information.
   1118 See the
   1119 .Sx Authentication Options
   1120 section for further information.
   1121 .It Cm loopstats
   1122 Enables recording of loop filter statistics information.
   1123 Each
   1124 update of the local clock outputs a line of the following form to
   1125 the file generation set named
   1126 .Cm loopstats :
   1127 .Bd -literal
   1128 50935 75440.031 0.000006019 13.778190 0.000351733 0.0133806
   1129 .Ed
   1130 .Pp
   1131 The first two fields show the date (Modified Julian Day) and
   1132 time (seconds and fraction past UTC midnight).
   1133 The next five fields
   1134 show time offset (seconds), frequency offset (parts per million -
   1135 PPM), RMS jitter (seconds), Allan deviation (PPM) and clock
   1136 discipline time constant.
   1137 .It Cm peerstats
   1138 Enables recording of peer statistics information.
   1139 This includes
   1140 statistics records of all peers of a NTP server and of special
   1141 signals, where present and configured.
   1142 Each valid update appends a
   1143 line of the following form to the current element of a file
   1144 generation set named
   1145 .Cm peerstats :
   1146 .Bd -literal
   1147 48773 10847.650 127.127.4.1 9714 -0.001605376 0.000000000 0.001424877 0.000958674
   1148 .Ed
   1149 .Pp
   1150 The first two fields show the date (Modified Julian Day) and
   1151 time (seconds and fraction past UTC midnight).
   1152 The next two fields
   1153 show the peer address in dotted-quad notation and status,
   1154 respectively.
   1155 The status field is encoded in hex in the format
   1156 described in Appendix A of the NTP specification RFC 1305.
   1157 The final four fields show the offset,
   1158 delay, dispersion and RMS jitter, all in seconds.
   1159 .It Cm rawstats
   1160 Enables recording of raw-timestamp statistics information.
   1161 This
   1162 includes statistics records of all peers of a NTP server and of
   1163 special signals, where present and configured.
   1164 Each NTP message
   1165 received from a peer or clock driver appends a line of the
   1166 following form to the file generation set named
   1167 .Cm rawstats :
   1168 .Bd -literal
   1169 50928 2132.543 128.4.1.1 128.4.1.20 3102453281.584327000 3102453281.58622800031 02453332.540806000 3102453332.541458000
   1170 .Ed
   1171 .Pp
   1172 The first two fields show the date (Modified Julian Day) and
   1173 time (seconds and fraction past UTC midnight).
   1174 The next two fields
   1175 show the remote peer or clock address followed by the local address
   1176 in dotted-quad notation.
   1177 The final four fields show the originate,
   1178 receive, transmit and final NTP timestamps in order.
   1179 The timestamp
   1180 values are as received and before processing by the various data
   1181 smoothing and mitigation algorithms.
   1182 .It Cm sysstats
   1183 Enables recording of ntpd statistics counters on a periodic basis.
   1184 Each
   1185 hour a line of the following form is appended to the file generation
   1186 set named
   1187 .Cm sysstats :
   1188 .Bd -literal
   1189 50928 2132.543 36000 81965 0 9546 56 71793 512 540 10 147
   1190 .Ed
   1191 .Pp
   1192 The first two fields show the date (Modified Julian Day) and time
   1193 (seconds and fraction past UTC midnight).
   1194 The remaining ten fields show
   1195 the statistics counter values accumulated since the last generated
   1196 line.
   1197 .Bl -tag -width indent
   1198 .It Time since restart Cm 36000
   1199 Time in hours since the system was last rebooted.
   1200 .It Packets received Cm 81965
   1201 Total number of packets received.
   1202 .It Packets processed Cm 0
   1203 Number of packets received in response to previous packets sent
   1204 .It Current version Cm 9546
   1205 Number of packets matching the current NTP version.
   1206 .It Previous version Cm 56
   1207 Number of packets matching the previous NTP version.
   1208 .It Bad version Cm 71793
   1209 Number of packets matching neither NTP version.
   1210 .It Access denied Cm 512
   1211 Number of packets denied access for any reason.
   1212 .It Bad length or format Cm 540
   1213 Number of packets with invalid length, format or port number.
   1214 .It Bad authentication Cm 10
   1215 Number of packets not verified as authentic.
   1216 .It Rate exceeded Cm 147
   1217 Number of packets discarded due to rate limitation.
   1218 .El
   1219 .It Cm statsdir Ar directory_path
   1220 Indicates the full path of a directory where statistics files
   1221 should be created (see below).
   1222 This keyword allows
   1223 the (otherwise constant)
   1224 .Cm filegen
   1225 filename prefix to be modified for file generation sets, which
   1226 is useful for handling statistics logs.
   1227 .It Cm filegen Ar name Xo
   1228 .Op Cm file Ar filename
   1229 .Op Cm type Ar typename
   1230 .Op Cm link | nolink
   1231 .Op Cm enable | disable
   1232 .Xc
   1233 Configures setting of generation file set name.
   1234 Generation
   1235 file sets provide a means for handling files that are
   1236 continuously growing during the lifetime of a server.
   1237 Server statistics are a typical example for such files.
   1238 Generation file sets provide access to a set of files used
   1239 to store the actual data.
   1240 At any time at most one element
   1241 of the set is being written to.
   1242 The type given specifies
   1243 when and how data will be directed to a new element of the set.
   1244 This way, information stored in elements of a file set
   1245 that are currently unused are available for administrational
   1246 operations without the risk of disturbing the operation of ntpd.
   1247 (Most important: they can be removed to free space for new data
   1248 produced.)
   1249 .Pp
   1250 Note that this command can be sent from the
   1251 .Xr ntpdc 1ntpdcmdoc
   1252 program running at a remote location.
   1253 .Bl -tag -width indent
   1254 .It Cm name
   1255 This is the type of the statistics records, as shown in the
   1256 .Cm statistics
   1257 command.
   1258 .It Cm file Ar filename
   1259 This is the file name for the statistics records.
   1260 Filenames of set
   1261 members are built from three concatenated elements
   1262 .Ar Cm prefix ,
   1263 .Ar Cm filename
   1264 and
   1265 .Ar Cm suffix :
   1266 .Bl -tag -width indent
   1267 .It Cm prefix
   1268 This is a constant filename path.
   1269 It is not subject to
   1270 modifications via the
   1271 .Ar filegen
   1272 option.
   1273 It is defined by the
   1274 server, usually specified as a compile-time constant.
   1275 It may,
   1276 however, be configurable for individual file generation sets
   1277 via other commands.
   1278 For example, the prefix used with
   1279 .Ar loopstats
   1280 and
   1281 .Ar peerstats
   1282 generation can be configured using the
   1283 .Ar statsdir
   1284 option explained above.
   1285 .It Cm filename
   1286 This string is directly concatenated to the prefix mentioned
   1287 above (no intervening
   1288 .Ql / ) .
   1289 This can be modified using
   1290 the file argument to the
   1291 .Ar filegen
   1292 statement.
   1293 No
   1294 .Pa ..
   1295 elements are
   1296 allowed in this component to prevent filenames referring to
   1297 parts outside the filesystem hierarchy denoted by
   1298 .Ar prefix .
   1299 .It Cm suffix
   1300 This part is reflects individual elements of a file set.
   1301 It is
   1302 generated according to the type of a file set.
   1303 .El
   1304 .It Cm type Ar typename
   1305 A file generation set is characterized by its type.
   1306 The following
   1307 types are supported:
   1308 .Bl -tag -width indent
   1309 .It Cm none
   1310 The file set is actually a single plain file.
   1311 .It Cm pid
   1312 One element of file set is used per incarnation of a ntpd
   1313 server.
   1314 This type does not perform any changes to file set
   1315 members during runtime, however it provides an easy way of
   1316 separating files belonging to different
   1317 .Xr ntpd 1ntpdmdoc
   1318 server incarnations.
   1319 The set member filename is built by appending a
   1320 .Ql \&.
   1321 to concatenated
   1322 .Ar prefix
   1323 and
   1324 .Ar filename
   1325 strings, and
   1326 appending the decimal representation of the process ID of the
   1327 .Xr ntpd 1ntpdmdoc
   1328 server process.
   1329 .It Cm day
   1330 One file generation set element is created per day.
   1331 A day is
   1332 defined as the period between 00:00 and 24:00 UTC.
   1333 The file set
   1334 member suffix consists of a
   1335 .Ql \&.
   1336 and a day specification in
   1337 the form
   1338 .Cm YYYYMMdd .
   1339 .Cm YYYY
   1340 is a 4-digit year number (e.g., 1992).
   1341 .Cm MM
   1342 is a two digit month number.
   1343 .Cm dd
   1344 is a two digit day number.
   1345 Thus, all information written at 10 December 1992 would end up
   1346 in a file named
   1347 .Ar prefix
   1348 .Ar filename Ns .19921210 .
   1349 .It Cm week
   1350 Any file set member contains data related to a certain week of
   1351 a year.
   1352 The term week is defined by computing day-of-year
   1353 modulo 7.
   1354 Elements of such a file generation set are
   1355 distinguished by appending the following suffix to the file set
   1356 filename base: A dot, a 4-digit year number, the letter
   1357 .Cm W ,
   1358 and a 2-digit week number.
   1359 For example, information from January,
   1360 10th 1992 would end up in a file with suffix
   1361 .No . Ns Ar 1992W1 .
   1362 .It Cm month
   1363 One generation file set element is generated per month.
   1364 The
   1365 file name suffix consists of a dot, a 4-digit year number, and
   1366 a 2-digit month.
   1367 .It Cm year
   1368 One generation file element is generated per year.
   1369 The filename
   1370 suffix consists of a dot and a 4 digit year number.
   1371 .It Cm age
   1372 This type of file generation sets changes to a new element of
   1373 the file set every 24 hours of server operation.
   1374 The filename
   1375 suffix consists of a dot, the letter
   1376 .Cm a ,
   1377 and an 8-digit number.
   1378 This number is taken to be the number of seconds the server is
   1379 running at the start of the corresponding 24-hour period.
   1380 Information is only written to a file generation by specifying
   1381 .Cm enable ;
   1382 output is prevented by specifying
   1383 .Cm disable .
   1384 .El
   1385 .It Cm link | nolink
   1386 It is convenient to be able to access the current element of a file
   1387 generation set by a fixed name.
   1388 This feature is enabled by
   1389 specifying
   1390 .Cm link
   1391 and disabled using
   1392 .Cm nolink .
   1393 If link is specified, a
   1394 hard link from the current file set element to a file without
   1395 suffix is created.
   1396 When there is already a file with this name and
   1397 the number of links of this file is one, it is renamed appending a
   1398 dot, the letter
   1399 .Cm C ,
   1400 and the pid of the
   1401 .Xr ntpd 1ntpdmdoc
   1402 server process.
   1403 When the
   1404 number of links is greater than one, the file is unlinked.
   1405 This
   1406 allows the current file to be accessed by a constant name.
   1407 .It Cm enable \&| Cm disable
   1408 Enables or disables the recording function.
   1409 .El
   1410 .El
   1411 .El
   1412 .Sh Access Control Support
   1413 The
   1414 .Xr ntpd 1ntpdmdoc
   1415 daemon implements a general purpose address/mask based restriction
   1416 list.
   1417 The list contains address/match entries sorted first
   1418 by increasing address values and and then by increasing mask values.
   1419 A match occurs when the bitwise AND of the mask and the packet
   1420 source address is equal to the bitwise AND of the mask and
   1421 address in the list.
   1422 The list is searched in order with the
   1423 last match found defining the restriction flags associated
   1424 with the entry.
   1425 Additional information and examples can be found in the
   1426 .Qq Notes on Configuring NTP and Setting up a NTP Subnet
   1427 page
   1428 (available as part of the HTML documentation
   1429 provided in
   1430 .Pa /usr/share/doc/ntp ) .
   1431 .Pp
   1432 The restriction facility was implemented in conformance
   1433 with the access policies for the original NSFnet backbone
   1434 time servers.
   1435 Later the facility was expanded to deflect
   1436 cryptographic and clogging attacks.
   1437 While this facility may
   1438 be useful for keeping unwanted or broken or malicious clients
   1439 from congesting innocent servers, it should not be considered
   1440 an alternative to the NTP authentication facilities.
   1441 Source address based restrictions are easily circumvented
   1442 by a determined cracker.
   1443 .Pp
   1444 Clients can be denied service because they are explicitly
   1445 included in the restrict list created by the
   1446 .Ic restrict
   1447 command
   1448 or implicitly as the result of cryptographic or rate limit
   1449 violations.
   1450 Cryptographic violations include certificate
   1451 or identity verification failure; rate limit violations generally
   1452 result from defective NTP implementations that send packets
   1453 at abusive rates.
   1454 Some violations cause denied service
   1455 only for the offending packet, others cause denied service
   1456 for a timed period and others cause the denied service for
   1457 an indefinite period.
   1458 When a client or network is denied access
   1459 for an indefinite period, the only way at present to remove
   1460 the restrictions is by restarting the server.
   1461 .Ss The Kiss-of-Death Packet
   1462 Ordinarily, packets denied service are simply dropped with no
   1463 further action except incrementing statistics counters.
   1464 Sometimes a
   1465 more proactive response is needed, such as a server message that
   1466 explicitly requests the client to stop sending and leave a message
   1467 for the system operator.
   1468 A special packet format has been created
   1469 for this purpose called the "kiss-of-death" (KoD) packet.
   1470 KoD packets have the leap bits set unsynchronized and stratum set
   1471 to zero and the reference identifier field set to a four-byte
   1472 ASCII code.
   1473 If the
   1474 .Cm noserve
   1475 or
   1476 .Cm notrust
   1477 flag of the matching restrict list entry is set,
   1478 the code is "DENY"; if the
   1479 .Cm limited
   1480 flag is set and the rate limit
   1481 is exceeded, the code is "RATE".
   1482 Finally, if a cryptographic violation occurs, the code is "CRYP".
   1483 .Pp
   1484 A client receiving a KoD performs a set of sanity checks to
   1485 minimize security exposure, then updates the stratum and
   1486 reference identifier peer variables, sets the access
   1487 denied (TEST4) bit in the peer flash variable and sends
   1488 a message to the log.
   1489 As long as the TEST4 bit is set,
   1490 the client will send no further packets to the server.
   1491 The only way at present to recover from this condition is
   1492 to restart the protocol at both the client and server.
   1493 This
   1494 happens automatically at the client when the association times out.
   1495 It will happen at the server only if the server operator cooperates.
   1496 .Ss Access Control Commands
   1497 .Bl -tag -width indent
   1498 .It Xo Ic discard
   1499 .Op Cm average Ar avg
   1500 .Op Cm minimum Ar min
   1501 .Op Cm monitor Ar prob
   1502 .Xc
   1503 Set the parameters of the
   1504 .Cm limited
   1505 facility which protects the server from
   1506 client abuse.
   1507 The
   1508 .Cm average
   1509 subcommand specifies the minimum average packet
   1510 spacing in log2 seconds, defaulting to 3 (8s), while the
   1511 .Cm minimum
   1512 subcommand specifies the minimum packet spacing
   1513 in seconds, defaulting to 2.
   1514 Packets that violate these minima are discarded
   1515 and a kiss-o'-death packet returned if enabled.
   1516 The
   1517 .Ic monitor
   1518 subcommand indirectly specifies the probability of
   1519 replacing the oldest entry from the monitor (MRU)
   1520 list of recent requests used to enforce rate controls,
   1521 when that list is at its maximum size. The probability
   1522 of replacing the oldest entry is the age of that entry
   1523 in seconds divided by the
   1524 .Ic monitor
   1525 value, default 3000. For example, if the oldest entry
   1526 in the MRU list represents a request 300 seconds ago,
   1527 by default the probability of replacing it with an
   1528 entry representing the client request being processed
   1529 now is 10%. Conversely, if the oldest entry is more
   1530 than 3000 seconds old, the probability is 100%.
   1531 .It Xo Ic restrict
   1532 .Ar address
   1533 .Op Cm mask Ar mask
   1534 .Op Cm ippeerlimit Ar int
   1535 .Op Ar flag ...
   1536 .Xc
   1537 The
   1538 .Ar address
   1539 argument expressed in
   1540 numeric form is the address of a host or network.
   1541 Alternatively, the
   1542 .Ar address
   1543 argument can be a valid hostname.  When a hostname
   1544 is provided, a restriction entry is created for each
   1545 address the hostname resolves to, and any provided
   1546 .Ar mask
   1547 is ignored and an individual host mask is
   1548 used for each entry.
   1549 The
   1550 .Ar mask
   1551 argument expressed in numeric form defaults to
   1552 all bits lit, meaning that the
   1553 .Ar address
   1554 is treated as the address of an individual host.
   1555 A default entry with address and mask all zeroes
   1556 is always included and is always the first entry in the list.
   1557 Note that text string
   1558 .Cm default ,
   1559 with no mask option, may
   1560 be used to indicate the default entry.
   1561 The
   1562 .Cm ippeerlimit
   1563 directive limits the number of peer requests for each IP to
   1564 .Ar int ,
   1565 where a value of -1 means "unlimited", the current default.
   1566 A value of 0 means "none".
   1567 There would usually be at most 1 peering request per IP,
   1568 but if the remote peering requests are behind a proxy
   1569 there could well be more than 1 per IP.
   1570 In the current implementation,
   1571 .Cm flag
   1572 always
   1573 restricts access, i.e., an entry with no flags indicates that free
   1574 access to the server is to be given.
   1575 The flags are not orthogonal,
   1576 in that more restrictive flags will often make less restrictive
   1577 ones redundant.
   1578 The flags can generally be classed into two
   1579 categories, those which restrict time service and those which
   1580 restrict informational queries and attempts to do run-time
   1581 reconfiguration of the server.
   1582 One or more of the following flags
   1583 may be specified:
   1584 .Bl -tag -width indent
   1585 .It Cm ignore
   1586 Deny packets of all kinds, including
   1587 .Xr ntpq 1ntpqmdoc
   1588 and
   1589 .Xr ntpdc 1ntpdcmdoc
   1590 queries.
   1591 .It Cm kod
   1592 If this flag is set when a rate violation occurs, a kiss-o'-death
   1593 (KoD) packet is sometimes sent.
   1594 KoD packets are rate limited to no more than one per minimum
   1595 average interpacket spacing, set by
   1596 .Cm discard average
   1597 defaulting to 8s.  Otherwise, no response is sent.
   1598 .It Cm limited
   1599 Deny service if the packet spacing violates the lower limits specified
   1600 in the
   1601 .Ic discard
   1602 command.
   1603 A history of clients is kept using the
   1604 monitoring capability of
   1605 .Xr ntpd 1ntpdmdoc .
   1606 Thus, monitoring is always active as
   1607 long as there is a restriction entry with the
   1608 .Cm limited
   1609 flag.
   1610 .It Cm lowpriotrap
   1611 Declare traps set by matching hosts to be low priority.
   1612 The
   1613 number of traps a server can maintain is limited (the current limit
   1614 is 3).
   1615 Traps are usually assigned on a first come, first served
   1616 basis, with later trap requestors being denied service.
   1617 This flag
   1618 modifies the assignment algorithm by allowing low priority traps to
   1619 be overridden by later requests for normal priority traps.
   1620 .It Cm noepeer
   1621 Deny ephemeral peer requests,
   1622 even if they come from an authenticated source.
   1623 Note that the ability to use a symmetric key for authentication may be restricted to
   1624 one or more IPs or subnets via the third field of the
   1625 .Pa ntp.keys
   1626 file.
   1627 This restriction is not enabled by default,
   1628 to maintain backward compatability.
   1629 Expect
   1630 .Cm noepeer
   1631 to become the default in ntp-4.4.
   1632 .It Cm nomodify
   1633 Deny
   1634 .Xr ntpq 1ntpqmdoc
   1635 and
   1636 .Xr ntpdc 1ntpdcmdoc
   1637 queries which attempt to modify the state of the
   1638 server (i.e., run time reconfiguration).
   1639 Queries which return
   1640 information are permitted.
   1641 .It Cm noquery
   1642 Deny
   1643 .Xr ntpq 1ntpqmdoc
   1644 and
   1645 .Xr ntpdc 1ntpdcmdoc
   1646 queries.
   1647 Time service is not affected.
   1648 .It Cm nopeer
   1649 Deny unauthenticated packets which would result in mobilizing a new association.
   1650 This includes
   1651 broadcast and symmetric active packets
   1652 when a configured association does not exist.
   1653 It also includes
   1654 .Cm pool
   1655 associations, so if you want to use servers from a
   1656 .Cm pool
   1657 directive and also want to use
   1658 .Cm nopeer
   1659 by default, you'll want a
   1660 .Cm "restrict source ..."
   1661 line as well that does
   1662 .Em not
   1663 include the
   1664 .Cm nopeer
   1665 directive.
   1666 .It Cm noserve
   1667 Deny all packets except
   1668 .Xr ntpq 1ntpqmdoc
   1669 and
   1670 .Xr ntpdc 1ntpdcmdoc
   1671 queries.
   1672 .It Cm notrap
   1673 Decline to provide mode 6 control message trap service to matching
   1674 hosts.
   1675 The trap service is a subsystem of the
   1676 .Xr ntpq 1ntpqmdoc
   1677 control message
   1678 protocol which is intended for use by remote event logging programs.
   1679 .It Cm notrust
   1680 Deny service unless the packet is cryptographically authenticated.
   1681 .It Cm ntpport
   1682 This is actually a match algorithm modifier, rather than a
   1683 restriction flag.
   1684 Its presence causes the restriction entry to be
   1685 matched only if the source port in the packet is the standard NTP
   1686 UDP port (123).
   1687 There can be two restriction entries with the same IP address if
   1688 one specifies
   1689 .Cm ntpport
   1690 and the other does not.
   1691 The
   1692 .Cm ntpport
   1693 entry is considered more specific and
   1694 is sorted later in the list.
   1695 .It Ic "serverresponse fuzz"
   1696 When reponding to server requests,
   1697 fuzz the low order bits of the
   1698 .Cm reftime .
   1699 .It Cm version
   1700 Deny packets that do not match the current NTP version.
   1701 .El
   1702 .Pp
   1703 Default restriction list entries with the flags ignore, interface,
   1704 ntpport, for each of the local host's interface addresses are
   1705 inserted into the table at startup to prevent ntpd
   1706 from attempting to synchronize to itself, such as with
   1707 .Cm manycastclient
   1708 when
   1709 .Cm manycast
   1710 is also specified with the same multicast address.
   1711 A default entry is also always present, though if it is
   1712 otherwise unconfigured; no flags are associated
   1713 with the default entry (i.e., everything besides your own
   1714 NTP server is unrestricted).
   1715 .It Xo Ic delrestrict
   1716 .Op source
   1717 .Ar address
   1718 .Xc
   1719 Remove a previously-set restriction.  This is useful for
   1720 runtime configuration via
   1721 .Xr ntpq 1ntpqmdoc
   1722 .  If
   1723 .Cm source
   1724 is specified, a dynamic restriction created from the
   1725 .Cm restrict source
   1726 template at the time
   1727 an association was added is removed.  Without
   1728 .Cm source
   1729 a static restriction is removed.
   1730 .El
   1731 .Sh Automatic NTP Configuration Options
   1732 .Ss Manycasting
   1733 Manycasting is a automatic discovery and configuration paradigm
   1734 new to NTPv4.
   1735 It is intended as a means for a multicast client
   1736 to troll the nearby network neighborhood to find cooperating
   1737 manycast servers, validate them using cryptographic means
   1738 and evaluate their time values with respect to other servers
   1739 that might be lurking in the vicinity.
   1740 The intended result is that each manycast client mobilizes
   1741 client associations with some number of the "best"
   1742 of the nearby manycast servers, yet automatically reconfigures
   1743 to sustain this number of servers should one or another fail.
   1744 .Pp
   1745 Note that the manycasting paradigm does not coincide
   1746 with the anycast paradigm described in RFC-1546,
   1747 which is designed to find a single server from a clique
   1748 of servers providing the same service.
   1749 The manycast paradigm is designed to find a plurality
   1750 of redundant servers satisfying defined optimality criteria.
   1751 .Pp
   1752 Manycasting can be used with either symmetric key
   1753 or public key cryptography.
   1754 The public key infrastructure (PKI)
   1755 offers the best protection against compromised keys
   1756 and is generally considered stronger, at least with relatively
   1757 large key sizes.
   1758 It is implemented using the Autokey protocol and
   1759 the OpenSSL cryptographic library available from
   1760 .Li http://www.openssl.org/ .
   1761 The library can also be used with other NTPv4 modes
   1762 as well and is highly recommended, especially for broadcast modes.
   1763 .Pp
   1764 A persistent manycast client association is configured
   1765 using the
   1766 .Ic manycastclient
   1767 command, which is similar to the
   1768 .Ic server
   1769 command but with a multicast (IPv4 class
   1770 .Cm D
   1771 or IPv6 prefix
   1772 .Cm FF )
   1773 group address.
   1774 The IANA has designated IPv4 address 224.1.1.1
   1775 and IPv6 address FF05::101 (site local) for NTP.
   1776 When more servers are needed, it broadcasts manycast
   1777 client messages to this address at the minimum feasible rate
   1778 and minimum feasible time-to-live (TTL) hops, depending
   1779 on how many servers have already been found.
   1780 There can be as many manycast client associations
   1781 as different group address, each one serving as a template
   1782 for a future ephemeral unicast client/server association.
   1783 .Pp
   1784 Manycast servers configured with the
   1785 .Ic manycastserver
   1786 command listen on the specified group address for manycast
   1787 client messages.
   1788 Note the distinction between manycast client,
   1789 which actively broadcasts messages, and manycast server,
   1790 which passively responds to them.
   1791 If a manycast server is
   1792 in scope of the current TTL and is itself synchronized
   1793 to a valid source and operating at a stratum level equal
   1794 to or lower than the manycast client, it replies to the
   1795 manycast client message with an ordinary unicast server message.
   1796 .Pp
   1797 The manycast client receiving this message mobilizes
   1798 an ephemeral client/server association according to the
   1799 matching manycast client template, but only if cryptographically
   1800 authenticated and the server stratum is less than or equal
   1801 to the client stratum.
   1802 Authentication is explicitly required
   1803 and either symmetric key or public key (Autokey) can be used.
   1804 Then, the client polls the server at its unicast address
   1805 in burst mode in order to reliably set the host clock
   1806 and validate the source.
   1807 This normally results
   1808 in a volley of eight client/server at 2-s intervals
   1809 during which both the synchronization and cryptographic
   1810 protocols run concurrently.
   1811 Following the volley,
   1812 the client runs the NTP intersection and clustering
   1813 algorithms, which act to discard all but the "best"
   1814 associations according to stratum and synchronization
   1815 distance.
   1816 The surviving associations then continue
   1817 in ordinary client/server mode.
   1818 .Pp
   1819 The manycast client polling strategy is designed to reduce
   1820 as much as possible the volume of manycast client messages
   1821 and the effects of implosion due to near-simultaneous
   1822 arrival of manycast server messages.
   1823 The strategy is determined by the
   1824 .Ic manycastclient ,
   1825 .Ic tos
   1826 and
   1827 .Ic ttl
   1828 configuration commands.
   1829 The manycast poll interval is
   1830 normally eight times the system poll interval,
   1831 which starts out at the
   1832 .Cm minpoll
   1833 value specified in the
   1834 .Ic manycastclient ,
   1835 command and, under normal circumstances, increments to the
   1836 .Cm maxpolll
   1837 value specified in this command.
   1838 Initially, the TTL is
   1839 set at the minimum hops specified by the
   1840 .Ic ttl
   1841 command.
   1842 At each retransmission the TTL is increased until reaching
   1843 the maximum hops specified by this command or a sufficient
   1844 number client associations have been found.
   1845 Further retransmissions use the same TTL.
   1846 .Pp
   1847 The quality and reliability of the suite of associations
   1848 discovered by the manycast client is determined by the NTP
   1849 mitigation algorithms and the
   1850 .Cm minclock
   1851 and
   1852 .Cm minsane
   1853 values specified in the
   1854 .Ic tos
   1855 configuration command.
   1856 At least
   1857 .Cm minsane
   1858 candidate servers must be available and the mitigation
   1859 algorithms produce at least
   1860 .Cm minclock
   1861 survivors in order to synchronize the clock.
   1862 Byzantine agreement principles require at least four
   1863 candidates in order to correctly discard a single falseticker.
   1864 For legacy purposes,
   1865 .Cm minsane
   1866 defaults to 1 and
   1867 .Cm minclock
   1868 defaults to 3.
   1869 For manycast service
   1870 .Cm minsane
   1871 should be explicitly set to 4, assuming at least that
   1872 number of servers are available.
   1873 .Pp
   1874 If at least
   1875 .Cm minclock
   1876 servers are found, the manycast poll interval is immediately
   1877 set to eight times
   1878 .Cm maxpoll .
   1879 If less than
   1880 .Cm minclock
   1881 servers are found when the TTL has reached the maximum hops,
   1882 the manycast poll interval is doubled.
   1883 For each transmission
   1884 after that, the poll interval is doubled again until
   1885 reaching the maximum of eight times
   1886 .Cm maxpoll .
   1887 Further transmissions use the same poll interval and
   1888 TTL values.
   1889 Note that while all this is going on,
   1890 each client/server association found is operating normally
   1891 it the system poll interval.
   1892 .Pp
   1893 Administratively scoped multicast boundaries are normally
   1894 specified by the network router configuration and,
   1895 in the case of IPv6, the link/site scope prefix.
   1896 By default, the increment for TTL hops is 32 starting
   1897 from 31; however, the
   1898 .Ic ttl
   1899 configuration command can be
   1900 used to modify the values to match the scope rules.
   1901 .Pp
   1902 It is often useful to narrow the range of acceptable
   1903 servers which can be found by manycast client associations.
   1904 Because manycast servers respond only when the client
   1905 stratum is equal to or greater than the server stratum,
   1906 primary (stratum 1) servers fill find only primary servers
   1907 in TTL range, which is probably the most common objective.
   1908 However, unless configured otherwise, all manycast clients
   1909 in TTL range will eventually find all primary servers
   1910 in TTL range, which is probably not the most common
   1911 objective in large networks.
   1912 The
   1913 .Ic tos
   1914 command can be used to modify this behavior.
   1915 Servers with stratum below
   1916 .Cm floor
   1917 or above
   1918 .Cm ceiling
   1919 specified in the
   1920 .Ic tos
   1921 command are strongly discouraged during the selection
   1922 process; however, these servers may be temporally
   1923 accepted if the number of servers within TTL range is
   1924 less than
   1925 .Cm minclock .
   1926 .Pp
   1927 The above actions occur for each manycast client message,
   1928 which repeats at the designated poll interval.
   1929 However, once the ephemeral client association is mobilized,
   1930 subsequent manycast server replies are discarded,
   1931 since that would result in a duplicate association.
   1932 If during a poll interval the number of client associations
   1933 falls below
   1934 .Cm minclock ,
   1935 all manycast client prototype associations are reset
   1936 to the initial poll interval and TTL hops and operation
   1937 resumes from the beginning.
   1938 It is important to avoid
   1939 frequent manycast client messages, since each one requires
   1940 all manycast servers in TTL range to respond.
   1941 The result could well be an implosion, either minor or major,
   1942 depending on the number of servers in range.
   1943 The recommended value for
   1944 .Cm maxpoll
   1945 is 12 (4,096 s).
   1946 .Pp
   1947 It is possible and frequently useful to configure a host
   1948 as both manycast client and manycast server.
   1949 A number of hosts configured this way and sharing a common
   1950 group address will automatically organize themselves
   1951 in an optimum configuration based on stratum and
   1952 synchronization distance.
   1953 For example, consider an NTP
   1954 subnet of two primary servers and a hundred or more
   1955 dependent clients.
   1956 With two exceptions, all servers
   1957 and clients have identical configuration files including both
   1958 .Ic multicastclient
   1959 and
   1960 .Ic multicastserver
   1961 commands using, for instance, multicast group address
   1962 239.1.1.1.
   1963 The only exception is that each primary server
   1964 configuration file must include commands for the primary
   1965 reference source such as a GPS receiver.
   1966 .Pp
   1967 The remaining configuration files for all secondary
   1968 servers and clients have the same contents, except for the
   1969 .Ic tos
   1970 command, which is specific for each stratum level.
   1971 For stratum 1 and stratum 2 servers, that command is
   1972 not necessary.
   1973 For stratum 3 and above servers the
   1974 .Cm floor
   1975 value is set to the intended stratum number.
   1976 Thus, all stratum 3 configuration files are identical,
   1977 all stratum 4 files are identical and so forth.
   1978 .Pp
   1979 Once operations have stabilized in this scenario,
   1980 the primary servers will find the primary reference source
   1981 and each other, since they both operate at the same
   1982 stratum (1), but not with any secondary server or client,
   1983 since these operate at a higher stratum.
   1984 The secondary
   1985 servers will find the servers at the same stratum level.
   1986 If one of the primary servers loses its GPS receiver,
   1987 it will continue to operate as a client and other clients
   1988 will time out the corresponding association and
   1989 re-associate accordingly.
   1990 .Pp
   1991 Some administrators prefer to avoid running
   1992 .Xr ntpd 1ntpdmdoc
   1993 continuously and run either
   1994 .Xr sntp 1sntpmdoc
   1995 or
   1996 .Xr ntpd 1ntpdmdoc
   1997 .Fl q
   1998 as a cron job.
   1999 In either case the servers must be
   2000 configured in advance and the program fails if none are
   2001 available when the cron job runs.
   2002 A really slick
   2003 application of manycast is with
   2004 .Xr ntpd 1ntpdmdoc
   2005 .Fl q .
   2006 The program wakes up, scans the local landscape looking
   2007 for the usual suspects, selects the best from among
   2008 the rascals, sets the clock and then departs.
   2009 Servers do not have to be configured in advance and
   2010 all clients throughout the network can have the same
   2011 configuration file.
   2012 .Ss Manycast Interactions with Autokey
   2013 Each time a manycast client sends a client mode packet
   2014 to a multicast group address, all manycast servers
   2015 in scope generate a reply including the host name
   2016 and status word.
   2017 The manycast clients then run
   2018 the Autokey protocol, which collects and verifies
   2019 all certificates involved.
   2020 Following the burst interval
   2021 all but three survivors are cast off,
   2022 but the certificates remain in the local cache.
   2023 It often happens that several complete signing trails
   2024 from the client to the primary servers are collected in this way.
   2025 .Pp
   2026 About once an hour or less often if the poll interval
   2027 exceeds this, the client regenerates the Autokey key list.
   2028 This is in general transparent in client/server mode.
   2029 However, about once per day the server private value
   2030 used to generate cookies is refreshed along with all
   2031 manycast client associations.
   2032 In this case all
   2033 cryptographic values including certificates is refreshed.
   2034 If a new certificate has been generated since
   2035 the last refresh epoch, it will automatically revoke
   2036 all prior certificates that happen to be in the
   2037 certificate cache.
   2038 At the same time, the manycast
   2039 scheme starts all over from the beginning and
   2040 the expanding ring shrinks to the minimum and increments
   2041 from there while collecting all servers in scope.
   2042 .Ss Broadcast Options
   2043 .Bl -tag -width indent
   2044 .It Xo Ic tos
   2045 .Oo
   2046 .Cm bcpollbstep Ar gate
   2047 .Oc
   2048 .Xc
   2049 This command provides a way to delay,
   2050 by the specified number of broadcast poll intervals,
   2051 believing backward time steps from a broadcast server.
   2052 Broadcast time networks are expected to be trusted.
   2053 In the event a broadcast server's time is stepped backwards,
   2054 there is clear benefit to having the clients notice this change
   2055 as soon as possible.
   2056 Attacks such as replay attacks can happen, however,
   2057 and even though there are a number of protections built in to
   2058 broadcast mode, attempts to perform a replay attack are possible.
   2059 This value defaults to 0, but can be changed
   2060 to any number of poll intervals between 0 and 4.
   2061 .El
   2062 .Ss Manycast Options
   2063 .Bl -tag -width indent
   2064 .It Xo Ic tos
   2065 .Oo
   2066 .Cm ceiling Ar ceiling |
   2067 .Cm cohort { 0 | 1 } |
   2068 .Cm floor Ar floor |
   2069 .Cm minclock Ar minclock |
   2070 .Cm minsane Ar minsane
   2071 .Oc
   2072 .Xc
   2073 This command affects the clock selection and clustering
   2074 algorithms.
   2075 It can be used to select the quality and
   2076 quantity of peers used to synchronize the system clock
   2077 and is most useful in manycast mode.
   2078 The variables operate
   2079 as follows:
   2080 .Bl -tag -width indent
   2081 .It Cm ceiling Ar ceiling
   2082 Peers with strata above
   2083 .Cm ceiling
   2084 will be discarded if there are at least
   2085 .Cm minclock
   2086 peers remaining.
   2087 This value defaults to 15, but can be changed
   2088 to any number from 1 to 15.
   2089 .It Cm cohort Bro 0 | 1 Brc
   2090 This is a binary flag which enables (0) or disables (1)
   2091 manycast server replies to manycast clients with the same
   2092 stratum level.
   2093 This is useful to reduce implosions where
   2094 large numbers of clients with the same stratum level
   2095 are present.
   2096 The default is to enable these replies.
   2097 .It Cm floor Ar floor
   2098 Peers with strata below
   2099 .Cm floor
   2100 will be discarded if there are at least
   2101 .Cm minclock
   2102 peers remaining.
   2103 This value defaults to 1, but can be changed
   2104 to any number from 1 to 15.
   2105 .It Cm minclock Ar minclock
   2106 The clustering algorithm repeatedly casts out outlier
   2107 associations until no more than
   2108 .Cm minclock
   2109 associations remain.
   2110 This value defaults to 3,
   2111 but can be changed to any number from 1 to the number of
   2112 configured sources.
   2113 .It Cm minsane Ar minsane
   2114 This is the minimum number of candidates available
   2115 to the clock selection algorithm in order to produce
   2116 one or more truechimers for the clustering algorithm.
   2117 If fewer than this number are available, the clock is
   2118 undisciplined and allowed to run free.
   2119 The default is 1
   2120 for legacy purposes.
   2121 However, according to principles of
   2122 Byzantine agreement,
   2123 .Cm minsane
   2124 should be at least 4 in order to detect and discard
   2125 a single falseticker.
   2126 .El
   2127 .It Cm ttl Ar hop ...
   2128 This command specifies a list of TTL values in increasing
   2129 order, up to 8 values can be specified.
   2130 In manycast mode these values are used in turn
   2131 in an expanding-ring search.
   2132 The default is eight
   2133 multiples of 32 starting at 31.
   2134 .El
   2135 .Sh Reference Clock Support
   2136 The NTP Version 4 daemon supports some three dozen different radio,
   2137 satellite and modem reference clocks plus a special pseudo-clock
   2138 used for backup or when no other clock source is available.
   2139 Detailed descriptions of individual device drivers and options can
   2140 be found in the
   2141 .Qq Reference Clock Drivers
   2142 page
   2143 (available as part of the HTML documentation
   2144 provided in
   2145 .Pa /usr/share/doc/ntp ) .
   2146 Additional information can be found in the pages linked
   2147 there, including the
   2148 .Qq Debugging Hints for Reference Clock Drivers
   2149 and
   2150 .Qq How To Write a Reference Clock Driver
   2151 pages
   2152 (available as part of the HTML documentation
   2153 provided in
   2154 .Pa /usr/share/doc/ntp ) .
   2155 In addition, support for a PPS
   2156 signal is available as described in the
   2157 .Qq Pulse-per-second (PPS) Signal Interfacing
   2158 page
   2159 (available as part of the HTML documentation
   2160 provided in
   2161 .Pa /usr/share/doc/ntp ) .
   2162 Many
   2163 drivers support special line discipline/streams modules which can
   2164 significantly improve the accuracy using the driver.
   2165 These are
   2166 described in the
   2167 .Qq Line Disciplines and Streams Drivers
   2168 page
   2169 (available as part of the HTML documentation
   2170 provided in
   2171 .Pa /usr/share/doc/ntp ) .
   2172 .Pp
   2173 A reference clock will generally (though not always) be a radio
   2174 timecode receiver which is synchronized to a source of standard
   2175 time such as the services offered by the NRC in Canada and NIST and
   2176 USNO in the US.
   2177 The interface between the computer and the timecode
   2178 receiver is device dependent, but is usually a serial port.
   2179 A
   2180 device driver specific to each reference clock must be selected and
   2181 compiled in the distribution; however, most common radio, satellite
   2182 and modem clocks are included by default.
   2183 Note that an attempt to
   2184 configure a reference clock when the driver has not been compiled
   2185 or the hardware port has not been appropriately configured results
   2186 in a scalding remark to the system log file, but is otherwise non
   2187 hazardous.
   2188 .Pp
   2189 For the purposes of configuration,
   2190 .Xr ntpd 1ntpdmdoc
   2191 treats
   2192 reference clocks in a manner analogous to normal NTP peers as much
   2193 as possible.
   2194 Reference clocks are identified by a syntactically
   2195 correct but invalid IP address, in order to distinguish them from
   2196 normal NTP peers.
   2197 Reference clock addresses are of the form
   2198 .Sm off
   2199 .Li 127.127. Ar t . Ar u ,
   2200 .Sm on
   2201 where
   2202 .Ar t
   2203 is an integer
   2204 denoting the clock type and
   2205 .Ar u
   2206 indicates the unit
   2207 number in the range 0-3.
   2208 While it may seem overkill, it is in fact
   2209 sometimes useful to configure multiple reference clocks of the same
   2210 type, in which case the unit numbers must be unique.
   2211 .Pp
   2212 The
   2213 .Ic server
   2214 command is used to configure a reference
   2215 clock, where the
   2216 .Ar address
   2217 argument in that command
   2218 is the clock address.
   2219 The
   2220 .Cm key ,
   2221 .Cm version
   2222 and
   2223 .Cm ttl
   2224 options are not used for reference clock support.
   2225 The
   2226 .Cm mode
   2227 option is added for reference clock support, as
   2228 described below.
   2229 The
   2230 .Cm prefer
   2231 option can be useful to
   2232 persuade the server to cherish a reference clock with somewhat more
   2233 enthusiasm than other reference clocks or peers.
   2234 Further
   2235 information on this option can be found in the
   2236 .Qq Mitigation Rules and the prefer Keyword
   2237 (available as part of the HTML documentation
   2238 provided in
   2239 .Pa /usr/share/doc/ntp )
   2240 page.
   2241 The
   2242 .Cm minpoll
   2243 and
   2244 .Cm maxpoll
   2245 options have
   2246 meaning only for selected clock drivers.
   2247 See the individual clock
   2248 driver document pages for additional information.
   2249 .Pp
   2250 The
   2251 .Ic fudge
   2252 command is used to provide additional
   2253 information for individual clock drivers and normally follows
   2254 immediately after the
   2255 .Ic server
   2256 command.
   2257 The
   2258 .Ar address
   2259 argument specifies the clock address.
   2260 The
   2261 .Cm refid
   2262 and
   2263 .Cm stratum
   2264 options can be used to
   2265 override the defaults for the device.
   2266 There are two optional
   2267 device-dependent time offsets and four flags that can be included
   2268 in the
   2269 .Ic fudge
   2270 command as well.
   2271 .Pp
   2272 The stratum number of a reference clock is by default zero.
   2273 Since the
   2274 .Xr ntpd 1ntpdmdoc
   2275 daemon adds one to the stratum of each
   2276 peer, a primary server ordinarily displays an external stratum of
   2277 one.
   2278 In order to provide engineered backups, it is often useful to
   2279 specify the reference clock stratum as greater than zero.
   2280 The
   2281 .Cm stratum
   2282 option is used for this purpose.
   2283 Also, in cases
   2284 involving both a reference clock and a pulse-per-second (PPS)
   2285 discipline signal, it is useful to specify the reference clock
   2286 identifier as other than the default, depending on the driver.
   2287 The
   2288 .Cm refid
   2289 option is used for this purpose.
   2290 Except where noted,
   2291 these options apply to all clock drivers.
   2292 .Ss Reference Clock Commands
   2293 .Bl -tag -width indent
   2294 .It Xo Ic server
   2295 .Sm off
   2296 .Li 127.127. Ar t . Ar u
   2297 .Sm on
   2298 .Op Cm prefer
   2299 .Op Cm mode Ar int
   2300 .Op Cm minpoll Ar int
   2301 .Op Cm maxpoll Ar int
   2302 .Xc
   2303 This command can be used to configure reference clocks in
   2304 special ways.
   2305 The options are interpreted as follows:
   2306 .Bl -tag -width indent
   2307 .It Cm prefer
   2308 Marks the reference clock as preferred.
   2309 All other things being
   2310 equal, this host will be chosen for synchronization among a set of
   2311 correctly operating hosts.
   2312 See the
   2313 .Qq Mitigation Rules and the prefer Keyword
   2314 page
   2315 (available as part of the HTML documentation
   2316 provided in
   2317 .Pa /usr/share/doc/ntp )
   2318 for further information.
   2319 .It Cm mode Ar int
   2320 Specifies a mode number which is interpreted in a
   2321 device-specific fashion.
   2322 For instance, it selects a dialing
   2323 protocol in the ACTS driver and a device subtype in the
   2324 parse
   2325 drivers.
   2326 .It Cm minpoll Ar int
   2327 .It Cm maxpoll Ar int
   2328 These options specify the minimum and maximum polling interval
   2329 for reference clock messages, as a power of 2 in seconds
   2330 For
   2331 most directly connected reference clocks, both
   2332 .Cm minpoll
   2333 and
   2334 .Cm maxpoll
   2335 default to 6 (64 s).
   2336 For modem reference clocks,
   2337 .Cm minpoll
   2338 defaults to 10 (17.1 m) and
   2339 .Cm maxpoll
   2340 defaults to 14 (4.5 h).
   2341 The allowable range is 4 (16 s) to 17 (36.4 h) inclusive.
   2342 .El
   2343 .It Xo Ic fudge
   2344 .Sm off
   2345 .Li 127.127. Ar t . Ar u
   2346 .Sm on
   2347 .Op Cm time1 Ar sec
   2348 .Op Cm time2 Ar sec
   2349 .Op Cm stratum Ar int
   2350 .Op Cm refid Ar string
   2351 .Op Cm mode Ar int
   2352 .Op Cm flag1 Cm 0 \&| Cm 1
   2353 .Op Cm flag2 Cm 0 \&| Cm 1
   2354 .Op Cm flag3 Cm 0 \&| Cm 1
   2355 .Op Cm flag4 Cm 0 \&| Cm 1
   2356 .Xc
   2357 This command can be used to configure reference clocks in
   2358 special ways.
   2359 It must immediately follow the
   2360 .Ic server
   2361 command which configures the driver.
   2362 Note that the same capability
   2363 is possible at run time using the
   2364 .Xr ntpdc 1ntpdcmdoc
   2365 program.
   2366 The options are interpreted as
   2367 follows:
   2368 .Bl -tag -width indent
   2369 .It Cm time1 Ar sec
   2370 Specifies a constant to be added to the time offset produced by
   2371 the driver, a fixed-point decimal number in seconds.
   2372 This is used
   2373 as a calibration constant to adjust the nominal time offset of a
   2374 particular clock to agree with an external standard, such as a
   2375 precision PPS signal.
   2376 It also provides a way to correct a
   2377 systematic error or bias due to serial port or operating system
   2378 latencies, different cable lengths or receiver internal delay.
   2379 The
   2380 specified offset is in addition to the propagation delay provided
   2381 by other means, such as internal DIPswitches.
   2382 Where a calibration
   2383 for an individual system and driver is available, an approximate
   2384 correction is noted in the driver documentation pages.
   2385 Note: in order to facilitate calibration when more than one
   2386 radio clock or PPS signal is supported, a special calibration
   2387 feature is available.
   2388 It takes the form of an argument to the
   2389 .Ic enable
   2390 command described in
   2391 .Sx Miscellaneous Options
   2392 page and operates as described in the
   2393 .Qq Reference Clock Drivers
   2394 page
   2395 (available as part of the HTML documentation
   2396 provided in
   2397 .Pa /usr/share/doc/ntp ) .
   2398 .It Cm time2 Ar secs
   2399 Specifies a fixed-point decimal number in seconds, which is
   2400 interpreted in a driver-dependent way.
   2401 See the descriptions of
   2402 specific drivers in the
   2403 .Qq Reference Clock Drivers
   2404 page
   2405 (available as part of the HTML documentation
   2406 provided in
   2407 .Pa /usr/share/doc/ntp ).
   2408 .It Cm stratum Ar int
   2409 Specifies the stratum number assigned to the driver, an integer
   2410 between 0 and 15.
   2411 This number overrides the default stratum number
   2412 ordinarily assigned by the driver itself, usually zero.
   2413 .It Cm refid Ar string
   2414 Specifies an ASCII string of from one to four characters which
   2415 defines the reference identifier used by the driver.
   2416 This string
   2417 overrides the default identifier ordinarily assigned by the driver
   2418 itself.
   2419 .It Cm mode Ar int
   2420 Specifies a mode number which is interpreted in a
   2421 device-specific fashion.
   2422 For instance, it selects a dialing
   2423 protocol in the ACTS driver and a device subtype in the
   2424 parse
   2425 drivers.
   2426 .It Cm flag1 Cm 0 \&| Cm 1
   2427 .It Cm flag2 Cm 0 \&| Cm 1
   2428 .It Cm flag3 Cm 0 \&| Cm 1
   2429 .It Cm flag4 Cm 0 \&| Cm 1
   2430 These four flags are used for customizing the clock driver.
   2431 The
   2432 interpretation of these values, and whether they are used at all,
   2433 is a function of the particular clock driver.
   2434 However, by
   2435 convention
   2436 .Cm flag4
   2437 is used to enable recording monitoring
   2438 data to the
   2439 .Cm clockstats
   2440 file configured with the
   2441 .Ic filegen
   2442 command.
   2443 Further information on the
   2444 .Ic filegen
   2445 command can be found in
   2446 .Sx Monitoring Options .
   2447 .El
   2448 .El
   2449 .Sh Miscellaneous Options
   2450 .Bl -tag -width indent
   2451 .It Ic broadcastdelay Ar seconds
   2452 The broadcast and multicast modes require a special calibration
   2453 to determine the network delay between the local and remote
   2454 servers.
   2455 Ordinarily, this is done automatically by the initial
   2456 protocol exchanges between the client and server.
   2457 In some cases,
   2458 the calibration procedure may fail due to network or server access
   2459 controls, for example.
   2460 This command specifies the default delay to
   2461 be used under these circumstances.
   2462 Typically (for Ethernet), a
   2463 number between 0.003 and 0.007 seconds is appropriate.
   2464 The default
   2465 when this command is not used is 0.004 seconds.
   2466 .It Ic driftfile Ar driftfile
   2467 This command specifies the complete path and name of the file used to
   2468 record the frequency of the local clock oscillator.
   2469 This is the same
   2470 operation as the
   2471 .Fl f
   2472 command line option.
   2473 If the file exists, it is read at
   2474 startup in order to set the initial frequency and then updated once per
   2475 hour with the current frequency computed by the daemon.
   2476 If the file name is
   2477 specified, but the file itself does not exist, the starts with an initial
   2478 frequency of zero and creates the file when writing it for the first time.
   2479 If this command is not given, the daemon will always start with an initial
   2480 frequency of zero.
   2481 .Pp
   2482 The file format consists of a single line containing a single
   2483 floating point number, which records the frequency offset measured
   2484 in parts-per-million (PPM).
   2485 The file is updated by first writing
   2486 the current drift value into a temporary file and then renaming
   2487 this file to replace the old version.
   2488 This implies that
   2489 .Xr ntpd 1ntpdmdoc
   2490 must have write permission for the directory the
   2491 drift file is located in, and that file system links, symbolic or
   2492 otherwise, should be avoided.
   2493 .It Ic dscp Ar value
   2494 This option specifies the Differentiated Services Control Point (DSCP) value,
   2495 a 6-bit code.
   2496 The default value is 46, signifying Expedited Forwarding.
   2497 .It Xo Ic enable
   2498 .Oo
   2499 .Cm auth | Cm bclient |
   2500 .Cm calibrate | Cm kernel |
   2501 .Cm mode7 | Cm monitor |
   2502 .Cm ntp | Cm stats |
   2503 .Cm peer_clear_digest_early |
   2504 .Cm unpeer_crypto_early | Cm unpeer_crypto_nak_early | Cm unpeer_digest_early
   2505 .Oc
   2506 .Xc
   2507 .It Xo Ic disable
   2508 .Oo
   2509 .Cm auth | Cm bclient |
   2510 .Cm calibrate | Cm kernel |
   2511 .Cm mode7 | Cm monitor |
   2512 .Cm ntp | Cm stats |
   2513 .Cm peer_clear_digest_early |
   2514 .Cm unpeer_crypto_early | Cm unpeer_crypto_nak_early | Cm unpeer_digest_early
   2515 .Oc
   2516 .Xc
   2517 Provides a way to enable or disable various server options.
   2518 Flags not mentioned are unaffected.
   2519 Note that all of these flags
   2520 can be controlled remotely using the
   2521 .Xr ntpdc 1ntpdcmdoc
   2522 utility program.
   2523 .Bl -tag -width indent
   2524 .It Cm auth
   2525 Enables the server to synchronize with unconfigured peers only if the
   2526 peer has been correctly authenticated using either public key or
   2527 private key cryptography.
   2528 The default for this flag is
   2529 .Ic enable .
   2530 .It Cm bclient
   2531 Enables the server to listen for a message from a broadcast or
   2532 multicast server, as in the
   2533 .Ic multicastclient
   2534 command with default
   2535 address.
   2536 The default for this flag is
   2537 .Ic disable .
   2538 .It Cm calibrate
   2539 Enables the calibrate feature for reference clocks.
   2540 The default for
   2541 this flag is
   2542 .Ic disable .
   2543 .It Cm kernel
   2544 Enables the kernel time discipline, if available.
   2545 The default for this
   2546 flag is
   2547 .Ic enable
   2548 if support is available, otherwise
   2549 .Ic disable .
   2550 .It Cm mode7
   2551 Enables processing of NTP mode 7 implementation-specific requests
   2552 which are used by the deprecated
   2553 .Xr ntpdc 1ntpdcmdoc
   2554 program.
   2555 The default for this flag is disable.
   2556 This flag is excluded from runtime configuration using
   2557 .Xr ntpq 1ntpqmdoc .
   2558 The
   2559 .Xr ntpq 1ntpqmdoc
   2560 program provides the same capabilities as
   2561 .Xr ntpdc 1ntpdcmdoc
   2562 using standard mode 6 requests.
   2563 .It Cm monitor
   2564 Enables the monitoring facility.
   2565 See the
   2566 .Xr ntpdc 1ntpdcmdoc
   2567 program
   2568 and the
   2569 .Ic monlist
   2570 command or further information.
   2571 The
   2572 default for this flag is
   2573 .Ic enable .
   2574 .It Cm ntp
   2575 Enables time and frequency discipline.
   2576 In effect, this switch opens and
   2577 closes the feedback loop, which is useful for testing.
   2578 The default for
   2579 this flag is
   2580 .Ic enable .
   2581 .It Cm peer_clear_digest_early
   2582 By default, if
   2583 .Xr ntpd 1ntpdmdoc
   2584 is using autokey and it
   2585 receives a crypto-NAK packet that
   2586 passes the duplicate packet and origin timestamp checks
   2587 the peer variables are immediately cleared.
   2588 While this is generally a feature
   2589 as it allows for quick recovery if a server key has changed,
   2590 a properly forged and appropriately delivered crypto-NAK packet
   2591 can be used in a DoS attack.
   2592 If you have active noticable problems with this type of DoS attack
   2593 then you should consider
   2594 disabling this option.
   2595 You can check your
   2596 .Cm peerstats
   2597 file for evidence of any of these attacks.
   2598 The
   2599 default for this flag is
   2600 .Ic enable .
   2601 .It Cm stats
   2602 Enables the statistics facility.
   2603 See the
   2604 .Sx Monitoring Options
   2605 section for further information.
   2606 The default for this flag is
   2607 .Ic disable .
   2608 .It Cm unpeer_crypto_early
   2609 By default, if
   2610 .Xr ntpd 1ntpdmdoc
   2611 receives an autokey packet that fails TEST9,
   2612 a crypto failure,
   2613 the association is immediately cleared.
   2614 This is almost certainly a feature,
   2615 but if, in spite of the current recommendation of not using autokey,
   2616 you are
   2617 .B still
   2618 using autokey
   2619 .B and
   2620 you are seeing this sort of DoS attack
   2621 disabling this flag will delay
   2622 tearing down the association until the reachability counter
   2623 becomes zero.
   2624 You can check your
   2625 .Cm peerstats
   2626 file for evidence of any of these attacks.
   2627 The
   2628 default for this flag is
   2629 .Ic enable .
   2630 .It Cm unpeer_crypto_nak_early
   2631 By default, if
   2632 .Xr ntpd 1ntpdmdoc
   2633 receives a crypto-NAK packet that
   2634 passes the duplicate packet and origin timestamp checks
   2635 the association is immediately cleared.
   2636 While this is generally a feature
   2637 as it allows for quick recovery if a server key has changed,
   2638 a properly forged and appropriately delivered crypto-NAK packet
   2639 can be used in a DoS attack.
   2640 If you have active noticable problems with this type of DoS attack
   2641 then you should consider
   2642 disabling this option.
   2643 You can check your
   2644 .Cm peerstats
   2645 file for evidence of any of these attacks.
   2646 The
   2647 default for this flag is
   2648 .Ic enable .
   2649 .It Cm unpeer_digest_early
   2650 By default, if
   2651 .Xr ntpd 1ntpdmdoc
   2652 receives what should be an authenticated packet
   2653 that passes other packet sanity checks but
   2654 contains an invalid digest
   2655 the association is immediately cleared.
   2656 While this is generally a feature
   2657 as it allows for quick recovery,
   2658 if this type of packet is carefully forged and sent
   2659 during an appropriate window it can be used for a DoS attack.
   2660 If you have active noticable problems with this type of DoS attack
   2661 then you should consider
   2662 disabling this option.
   2663 You can check your
   2664 .Cm peerstats
   2665 file for evidence of any of these attacks.
   2666 The
   2667 default for this flag is
   2668 .Ic enable .
   2669 .El
   2670 .It Ic includefile Ar includefile
   2671 This command allows additional configuration commands
   2672 to be included from a separate file.
   2673 Include files may
   2674 be nested to a depth of five; upon reaching the end of any
   2675 include file, command processing resumes in the previous
   2676 configuration file.
   2677 This option is useful for sites that run
   2678 .Xr ntpd 1ntpdmdoc
   2679 on multiple hosts, with (mostly) common options (e.g., a
   2680 restriction list).
   2681 .It Xo Ic interface
   2682 .Oo
   2683 .Cm listen | Cm ignore | Cm drop
   2684 .Oc
   2685 .Oo
   2686 .Cm all | Cm ipv4 | Cm ipv6 | Cm wildcard
   2687 .Ar name | Ar address
   2688 .Oo Cm / Ar prefixlen
   2689 .Oc
   2690 .Oc
   2691 .Xc
   2692 The
   2693 .Cm interface
   2694 directive controls which network addresses
   2695 .Xr ntpd 1ntpdmdoc
   2696 opens, and whether input is dropped without processing.
   2697 The first parameter determines the action for addresses
   2698 which match the second parameter.
   2699 The second parameter specifies a class of addresses,
   2700 or a specific interface name,
   2701 or an address.
   2702 In the address case,
   2703 .Ar prefixlen
   2704 determines how many bits must match for this rule to apply.
   2705 .Cm ignore
   2706 prevents opening matching addresses,
   2707 .Cm drop
   2708 causes
   2709 .Xr ntpd 1ntpdmdoc
   2710 to open the address and drop all received packets without examination.
   2711 Multiple
   2712 .Cm interface
   2713 directives can be used.
   2714 The last rule which matches a particular address determines the action for it.
   2715 .Cm interface
   2716 directives are disabled if any
   2717 .Fl I ,
   2718 .Fl -interface ,
   2719 .Fl L ,
   2720 or
   2721 .Fl -novirtualips
   2722 command-line options are specified in the configuration file,
   2723 all available network addresses are opened.
   2724 The
   2725 .Cm nic
   2726 directive is an alias for
   2727 .Cm interface .
   2728 .It Ic leapfile Ar leapfile
   2729 This command loads the IERS leapseconds file and initializes the
   2730 leapsecond values for the next leapsecond event, leapfile expiration
   2731 time, and TAI offset.
   2732 The file can be obtained directly from the IERS at
   2733 .Li https://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list
   2734 or
   2735 .Li ftp://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list .
   2736 The
   2737 .Cm leapfile
   2738 is scanned when
   2739 .Xr ntpd 1ntpdmdoc
   2740 processes the
   2741 .Cm leapfile directive or when
   2742 .Cm ntpd detects that the
   2743 .Ar leapfile
   2744 has changed.
   2745 .Cm ntpd
   2746 checks once a day to see if the
   2747 .Ar leapfile
   2748 has changed.
   2749 The
   2750 .Xr update-leap 1update_leapmdoc
   2751 script can be run to see if the
   2752 .Ar leapfile
   2753 should be updated.
   2754 .It Ic leapsmearinterval Ar seconds
   2755 This EXPERIMENTAL option is only available if
   2756 .Xr ntpd 1ntpdmdoc
   2757 was built with the
   2758 .Cm --enable-leap-smear
   2759 option to the
   2760 .Cm configure
   2761 script.
   2762 It specifies the interval over which a leap second correction will be applied.
   2763 Recommended values for this option are between
   2764 7200 (2 hours) and 86400 (24 hours).
   2765 .Sy DO NOT USE THIS OPTION ON PUBLIC-ACCESS SERVERS!
   2766 See http://bugs.ntp.org/2855 for more information.
   2767 .It Ic logconfig Ar configkeyword
   2768 This command controls the amount and type of output written to
   2769 the system
   2770 .Xr syslog 3
   2771 facility or the alternate
   2772 .Ic logfile
   2773 log file.
   2774 By default, all output is turned on.
   2775 All
   2776 .Ar configkeyword
   2777 keywords can be prefixed with
   2778 .Ql = ,
   2779 .Ql +
   2780 and
   2781 .Ql - ,
   2782 where
   2783 .Ql =
   2784 sets the
   2785 .Xr syslog 3
   2786 priority mask,
   2787 .Ql +
   2788 adds and
   2789 .Ql -
   2790 removes
   2791 messages.
   2792 .Xr syslog 3
   2793 messages can be controlled in four
   2794 classes
   2795 .Po
   2796 .Cm clock ,
   2797 .Cm peer ,
   2798 .Cm sys
   2799 and
   2800 .Cm sync
   2801 .Pc .
   2802 Within these classes four types of messages can be
   2803 controlled: informational messages
   2804 .Po
   2805 .Cm info
   2806 .Pc ,
   2807 event messages
   2808 .Po
   2809 .Cm events
   2810 .Pc ,
   2811 statistics messages
   2812 .Po
   2813 .Cm statistics
   2814 .Pc
   2815 and
   2816 status messages
   2817 .Po
   2818 .Cm status
   2819 .Pc .
   2820 .Pp
   2821 Configuration keywords are formed by concatenating the message class with
   2822 the event class.
   2823 The
   2824 .Cm all
   2825 prefix can be used instead of a message class.
   2826 A
   2827 message class may also be followed by the
   2828 .Cm all
   2829 keyword to enable/disable all
   2830 messages of the respective message class.
   2831 Thus, a minimal log configuration
   2832 could look like this:
   2833 .Bd -literal
   2834 logconfig =syncstatus +sysevents
   2835 .Ed
   2836 .Pp
   2837 This would just list the synchronizations state of
   2838 .Xr ntpd 1ntpdmdoc
   2839 and the major system events.
   2840 For a simple reference server, the
   2841 following minimum message configuration could be useful:
   2842 .Bd -literal
   2843 logconfig =syncall +clockall
   2844 .Ed
   2845 .Pp
   2846 This configuration will list all clock information and
   2847 synchronization information.
   2848 All other events and messages about
   2849 peers, system events and so on is suppressed.
   2850 .It Ic logfile Ar logfile
   2851 This command specifies the location of an alternate log file to
   2852 be used instead of the default system
   2853 .Xr syslog 3
   2854 facility.
   2855 This is the same operation as the
   2856 .Fl l
   2857 command line option.
   2858 .It Xo Ic mru
   2859 .Oo
   2860 .Cm maxdepth Ar count | Cm maxmem Ar kilobytes |
   2861 .Cm mindepth Ar count | Cm maxage Ar seconds |
   2862 .Cm initialloc Ar count | Cm initmem Ar kilobytes |
   2863 .Cm incalloc Ar count | Cm incmem Ar kilobytes
   2864 .Oc
   2865 .Xc
   2866 Controls size limite of the monitoring facility's Most Recently Used
   2867 (MRU) list
   2868 of client addresses, which is also used by the
   2869 rate control facility.
   2870 .Bl -tag -width indent
   2871 .It Ic maxdepth Ar count
   2872 .It Ic maxmem Ar kilobytes
   2873 Equivalent upper limits on the size of the MRU list, in terms of entries or kilobytes.
   2874 The acutal limit will be up to
   2875 .Cm incalloc
   2876 entries or
   2877 .Cm incmem
   2878 kilobytes larger.
   2879 As with all of the
   2880 .Cm mru
   2881 options offered in units of entries or kilobytes, if both
   2882 .Cm maxdepth
   2883 and
   2884 .Cm maxmem are used, the last one used controls.
   2885 The default is 1024 kilobytes.
   2886 .It Cm mindepth Ar count
   2887 Lower limit on the MRU list size.
   2888 When the MRU list has fewer than
   2889 .Cm mindepth
   2890 entries, existing entries are never removed to make room for newer ones,
   2891 regardless of their age.
   2892 The default is 600 entries.
   2893 .It Cm maxage Ar seconds
   2894 Once the MRU list has
   2895 .Cm mindepth
   2896 entries and an additional client is to ba added to the list,
   2897 if the oldest entry was updated more than
   2898 .Cm maxage
   2899 seconds ago, that entry is removed and its storage is reused.
   2900 If the oldest entry was updated more recently the MRU list is grown,
   2901 subject to
   2902 .Cm maxdepth / moxmem .
   2903 The default is 64 seconds.
   2904 .It Cm initalloc Ar count
   2905 .It Cm initmem Ar kilobytes
   2906 Initial memory allocation at the time the monitoringfacility is first enabled,
   2907 in terms of the number of entries or kilobytes.
   2908 The default is 4 kilobytes.
   2909 .It Cm incalloc Ar count
   2910 .It Cm incmem Ar kilobytes
   2911 Size of additional memory allocations when growing the MRU list, in entries or kilobytes.
   2912 The default is 4 kilobytes.
   2913 .El
   2914 .It Ic nonvolatile Ar threshold
   2915 Specify the
   2916 .Ar threshold
   2917 delta in seconds before an hourly change to the
   2918 .Cm driftfile
   2919 (frequency file) will be written, with a default value of 1e-7 (0.1 PPM).
   2920 The frequency file is inspected each hour.
   2921 If the difference between the current frequency and the last value written
   2922 exceeds the threshold, the file is written and the
   2923 .Cm threshold
   2924 becomes the new threshold value.
   2925 If the threshold is not exceeeded, it is reduced by half.
   2926 This is intended to reduce the number of file writes
   2927 for embedded systems with nonvolatile memory.
   2928 .It Ic phone Ar dial ...
   2929 This command is used in conjunction with
   2930 the ACTS modem driver (type 18)
   2931 or the JJY driver (type 40, mode 100 - 180).
   2932 For the ACTS modem driver (type 18), the arguments consist of
   2933 a maximum of 10 telephone numbers used to dial USNO, NIST, or European
   2934 time service.
   2935 For the JJY driver (type 40 mode 100 - 180), the argument is
   2936 one telephone number used to dial the telephone JJY service.
   2937 The Hayes command ATDT is normally prepended to the number.
   2938 The number can contain other modem control codes as well.
   2939 .It Xo Cm pollskewlist
   2940 .Oo
   2941 .Ar poll
   2942 .Ar early late
   2943 .Oc
   2944 .Ar ...
   2945 .Oo
   2946 .Cm default
   2947 .Ar early late
   2948 .Oc
   2949 .Xc
   2950 Enable skewing of our poll requests to our servers.
   2951 .Ar poll
   2952 is a number between 3 and 17 inclusive, identifying a specific poll interval.
   2953 A poll interval is 2^n seconds in duration,
   2954 so a poll value of 3 corresponds to 8 seconds
   2955 and
   2956 a poll interval of 17 corresponds to
   2957 131,072 seconds, or about a day and a half.
   2958 The next two numbers must be between 0 and one-half of the poll interval,
   2959 inclusive.
   2960 Ar early
   2961 specifies how early the poll may start,
   2962 while
   2963 Ar late
   2964 specifies how late the poll may be delayed.
   2965 With no arguments, internally specified default values are chosen.
   2966 .It Xo Ic reset
   2967 .Oo
   2968 .Ic allpeers
   2969 .Oc
   2970 .Oo
   2971 .Ic auth
   2972 .Oc
   2973 .Oo
   2974 .Ic ctl
   2975 .Oc
   2976 .Oo
   2977 .Ic io
   2978 .Oc
   2979 .Oo
   2980 .Ic mem
   2981 .Oc
   2982 .Oo
   2983 .Ic sys
   2984 .Oc
   2985 .Oo
   2986 .Ic timer
   2987 .Oc
   2988 .Xc
   2989 Reset one or more groups of counters maintained by
   2990 .Cm ntpd
   2991 and exposed by
   2992 .Cm ntpq
   2993 and
   2994 .Cm ntpdc .
   2995 .It Xo Ic rlimit
   2996 .Oo
   2997 .Cm memlock Ar Nmegabytes |
   2998 .Cm stacksize Ar N4kPages
   2999 .Cm filenum Ar Nfiledescriptors
   3000 .Oc
   3001 .Xc
   3002 .Bl -tag -width indent
   3003 .It Cm memlock Ar Nmegabytes
   3004 Specify the number of megabytes of memory that should be
   3005 allocated and locked.
   3006 Probably only available under Linux, this option may be useful
   3007 when dropping root (the
   3008 .Fl i
   3009 option).
   3010 The default is 32 megabytes on non-Linux machines, and -1 under Linux.
   3011 -1 means "do not lock the process into memory".
   3012 0 means "lock whatever memory the process wants into memory".
   3013 .It Cm stacksize Ar N4kPages
   3014 Specifies the maximum size of the process stack on systems with the
   3015 .Fn mlockall
   3016 function.
   3017 Defaults to 50 4k pages (200 4k pages in OpenBSD).
   3018 .It Cm filenum Ar Nfiledescriptors
   3019 Specifies the maximum number of file descriptors ntpd may have open at once.
   3020 Defaults to the system default.
   3021 .El
   3022 .It Ic saveconfigdir Ar directory_path
   3023 Specify the directory in which to write configuration snapshots
   3024 requested with
   3025 .Cm ntpq 's
   3026 .Cm saveconfig
   3027 command.
   3028 If
   3029 .Cm saveconfigdir
   3030 does not appear in the configuration file,
   3031 .Cm saveconfig
   3032 requests are rejected by
   3033 .Cm ntpd .
   3034 .It Ic saveconfig Ar filename
   3035 Write the current configuration, including any runtime
   3036 modifications given with
   3037 .Cm :config
   3038 or
   3039 .Cm config-from-file
   3040 to the
   3041 .Cm ntpd
   3042 host's
   3043 .Ar filename
   3044 in the
   3045 .Cm saveconfigdir .
   3046 This command will be rejected unless the
   3047 .Cm saveconfigdir
   3048 directive appears in
   3049 .Cm ntpd 's
   3050 configuration file.
   3051 .Ar filename
   3052 can use
   3053 .Xr strftime 3
   3054 format directives to substitute the current date and time,
   3055 for example,
   3056 .Cm saveconfig\ ntp-%Y%m%d-%H%M%S.conf .
   3057 The filename used is stored in the system variable
   3058 .Cm savedconfig .
   3059 Authentication is required.
   3060 .It Ic setvar Ar variable Op Cm default
   3061 This command adds an additional system variable.
   3062 These
   3063 variables can be used to distribute additional information such as
   3064 the access policy.
   3065 If the variable of the form
   3066 .Sm off
   3067 .Va name = Ar value
   3068 .Sm on
   3069 is followed by the
   3070 .Cm default
   3071 keyword, the
   3072 variable will be listed as part of the default system variables
   3073 .Po
   3074 .Xr ntpq 1ntpqmdoc
   3075 .Ic rv
   3076 command
   3077 .Pc ) .
   3078 These additional variables serve
   3079 informational purposes only.
   3080 They are not related to the protocol
   3081 other that they can be listed.
   3082 The known protocol variables will
   3083 always override any variables defined via the
   3084 .Ic setvar
   3085 mechanism.
   3086 There are three special variables that contain the names
   3087 of all variable of the same group.
   3088 The
   3089 .Va sys_var_list
   3090 holds
   3091 the names of all system variables.
   3092 The
   3093 .Va peer_var_list
   3094 holds
   3095 the names of all peer variables and the
   3096 .Va clock_var_list
   3097 holds the names of the reference clock variables.
   3098 .It Cm sysinfo
   3099 Display operational summary.
   3100 .It Cm sysstats
   3101 Show statistics counters maintained in the protocol module.
   3102 .It Xo Ic tinker
   3103 .Oo
   3104 .Cm allan Ar allan |
   3105 .Cm dispersion Ar dispersion |
   3106 .Cm freq Ar freq |
   3107 .Cm huffpuff Ar huffpuff |
   3108 .Cm panic Ar panic |
   3109 .Cm step Ar step |
   3110 .Cm stepback Ar stepback |
   3111 .Cm stepfwd Ar stepfwd |
   3112 .Cm stepout Ar stepout
   3113 .Oc
   3114 .Xc
   3115 This command can be used to alter several system variables in
   3116 very exceptional circumstances.
   3117 It should occur in the
   3118 configuration file before any other configuration options.
   3119 The
   3120 default values of these variables have been carefully optimized for
   3121 a wide range of network speeds and reliability expectations.
   3122 In
   3123 general, they interact in intricate ways that are hard to predict
   3124 and some combinations can result in some very nasty behavior.
   3125 Very
   3126 rarely is it necessary to change the default values; but, some
   3127 folks cannot resist twisting the knobs anyway and this command is
   3128 for them.
   3129 Emphasis added: twisters are on their own and can expect
   3130 no help from the support group.
   3131 .Pp
   3132 The variables operate as follows:
   3133 .Bl -tag -width indent
   3134 .It Cm allan Ar allan
   3135 The argument becomes the new value for the minimum Allan
   3136 intercept, which is a parameter of the PLL/FLL clock discipline
   3137 algorithm.
   3138 The value in log2 seconds defaults to 7 (1024 s), which is also the lower
   3139 limit.
   3140 .It Cm dispersion Ar dispersion
   3141 The argument becomes the new value for the dispersion increase rate,
   3142 normally .000015 s/s.
   3143 .It Cm freq Ar freq
   3144 The argument becomes the initial value of the frequency offset in
   3145 parts-per-million.
   3146 This overrides the value in the frequency file, if
   3147 present, and avoids the initial training state if it is not.
   3148 .It Cm huffpuff Ar huffpuff
   3149 The argument becomes the new value for the experimental
   3150 huff-n'-puff filter span, which determines the most recent interval
   3151 the algorithm will search for a minimum delay.
   3152 The lower limit is
   3153 900 s (15 m), but a more reasonable value is 7200 (2 hours).
   3154 There
   3155 is no default, since the filter is not enabled unless this command
   3156 is given.
   3157 .It Cm panic Ar panic
   3158 The argument is the panic threshold, normally 1000 s.
   3159 If set to zero,
   3160 the panic sanity check is disabled and a clock offset of any value will
   3161 be accepted.
   3162 .It Cm step Ar step
   3163 The argument is the step threshold, which by default is 0.128 s.
   3164 It can
   3165 be set to any positive number in seconds.
   3166 If set to zero, step
   3167 adjustments will never occur.
   3168 Note: The kernel time discipline is
   3169 disabled if the step threshold is set to zero or greater than the
   3170 default.
   3171 .It Cm stepback Ar stepback
   3172 The argument is the step threshold for the backward direction,
   3173 which by default is 0.128 s.
   3174 It can
   3175 be set to any positive number in seconds.
   3176 If both the forward and backward step thresholds are set to zero, step
   3177 adjustments will never occur.
   3178 Note: The kernel time discipline is
   3179 disabled if
   3180 each direction of step threshold are either
   3181 set to zero or greater than .5 second.
   3182 .It Cm stepfwd Ar stepfwd
   3183 As for stepback, but for the forward direction.
   3184 .It Cm stepout Ar stepout
   3185 The argument is the stepout timeout, which by default is 900 s.
   3186 It can
   3187 be set to any positive number in seconds.
   3188 If set to zero, the stepout
   3189 pulses will not be suppressed.
   3190 .El
   3191 .It Cm writevar Ar assocID\ name = value [,...]
   3192 Write (create or update) the specified variables.
   3193 If the
   3194 .Cm assocID
   3195 is zero, the variablea re from the
   3196 system variables
   3197 name space, otherwise they are from the
   3198 peer variables
   3199 name space.
   3200 The
   3201 .Cm assocID
   3202 is required, as the same name can occur in both name spaces.
   3203 .It Xo Ic trap Ar host_address
   3204 .Op Cm port Ar port_number
   3205 .Op Cm interface Ar interface_address
   3206 .Xc
   3207 This command configures a trap receiver at the given host
   3208 address and port number for sending messages with the specified
   3209 local interface address.
   3210 If the port number is unspecified, a value
   3211 of 18447 is used.
   3212 If the interface address is not specified, the
   3213 message is sent with a source address of the local interface the
   3214 message is sent through.
   3215 Note that on a multihomed host the
   3216 interface used may vary from time to time with routing changes.
   3217 .It Cm ttl Ar hop ...
   3218 This command specifies a list of TTL values in increasing order.
   3219 Up to 8 values can be specified.
   3220 In
   3221 .Cm manycast
   3222 mode these values are used in-turn in an expanding-ring search.
   3223 The default is eight multiples of 32 starting at 31.
   3224 .Pp
   3225 The trap receiver will generally log event messages and other
   3226 information from the server in a log file.
   3227 While such monitor
   3228 programs may also request their own trap dynamically, configuring a
   3229 trap receiver will ensure that no messages are lost when the server
   3230 is started.
   3231 .It Cm hop Ar ...
   3232 This command specifies a list of TTL values in increasing order, up to 8
   3233 values can be specified.
   3234 In manycast mode these values are used in turn in
   3235 an expanding-ring search.
   3236 The default is eight multiples of 32 starting at
   3237 31.
   3238 .El
   3239 	_END_PROG_MDOC_DESCRIP;
   3240 };
   3241 
   3242 doc-section	= {
   3243   ds-type	= 'FILES';
   3244   ds-format	= 'mdoc';
   3245   ds-text	= <<- _END_MDOC_FILES
   3246 .Bl -tag -width /etc/ntp.drift -compact
   3247 .It Pa /etc/ntp.conf
   3248 the default name of the configuration file
   3249 .It Pa ntp.keys
   3250 private MD5 keys
   3251 .It Pa ntpkey
   3252 RSA private key
   3253 .It Pa ntpkey_ Ns Ar host
   3254 RSA public key
   3255 .It Pa ntp_dh
   3256 Diffie-Hellman agreement parameters
   3257 .El
   3258 	_END_MDOC_FILES;
   3259 };
   3260 
   3261 doc-section	= {
   3262   ds-type	= 'SEE ALSO';
   3263   ds-format	= 'mdoc';
   3264   ds-text	= <<- _END_MDOC_SEE_ALSO
   3265 .Xr ntpd 1ntpdmdoc ,
   3266 .Xr ntpdc 1ntpdcmdoc ,
   3267 .Xr ntpq 1ntpqmdoc
   3268 .Pp
   3269 In addition to the manual pages provided,
   3270 comprehensive documentation is available on the world wide web
   3271 at
   3272 .Li http://www.ntp.org/ .
   3273 A snapshot of this documentation is available in HTML format in
   3274 .Pa /usr/share/doc/ntp .
   3275 .Rs
   3276 .%A David L. Mills
   3277 .%T Network Time Protocol (Version 4)
   3278 .%O RFC5905
   3279 .Re
   3280 	_END_MDOC_SEE_ALSO;
   3281 };
   3282 
   3283 doc-section	= {
   3284   ds-type	= 'BUGS';
   3285   ds-format	= 'mdoc';
   3286   ds-text	= <<- _END_MDOC_BUGS
   3287 The syntax checking is not picky; some combinations of
   3288 ridiculous and even hilarious options and modes may not be
   3289 detected.
   3290 .Pp
   3291 The
   3292 .Pa ntpkey_ Ns Ar host
   3293 files are really digital
   3294 certificates.
   3295 These should be obtained via secure directory
   3296 services when they become universally available.
   3297 	_END_MDOC_BUGS;
   3298 };
   3299 
   3300 doc-section	= {
   3301   ds-type	= 'NOTES';
   3302   ds-format	= 'mdoc';
   3303   ds-text	= <<- _END_MDOC_NOTES
   3304 This document was derived from FreeBSD.
   3305 	_END_MDOC_NOTES;
   3306 };
   3307