# NTP Configuration File User's Manual

## NTP's Configuration File User Manual

This document describes the configuration file for the NTP Project's `ntpd` program.

This document applies to version 4.2.7p364 of `ntp.conf`.

### Description

The behavior of `ntpd` can be changed by a configuration file, by default `ntp.conf`.

### Notes about ntp.conf

The `ntp.conf` configuration file is read at initial startup by the `ntpd(1ntpdmdoc)` daemon in order to specify the synchronization sources, modes and other related information. Usually, it is installed in the /etc directory, but could be installed elsewhere (see the daemon's `-c` command line option).

The file format is similar to other UNIX configuration files. Comments begin with a # character and extend to the end of the line; blank lines are ignored. Configuration commands consist of an initial keyword followed by a list of arguments, some of which may be optional, separated by whitespace. Commands may not be continued over multiple lines. Arguments may be host names, host addresses written in numeric, dotted-quad form, integers, floating point numbers (when specifying times in seconds) and text strings.

The rest of this page describes the configuration and control options. The "Notes on Configuring NTP and Setting up an NTP Subnet" page (available as part of the HTML documentation provided in /usr/share/doc/ntp) contains an extended discussion of these options. In addition to the discussion of general Configuration Options, there are sections describing the following supported functionality and the options used to control it:

- Authentication Support
- Monitoring Support
- Access Control Support
- Automatic NTP Configuration Options
- Reference Clock Support
- Miscellaneous Options

Following these is a section describing Miscellaneous Options. While there is a rich set of options available, the only required option is one or more `pool`, `server`, `peer`, `broadcast` or `manycastclient` commands.

### Configuration Support

Following is a description of the configuration commands in NTPv4. These commands have the same basic functions as in NTPv3 and in some cases new functions and new arguments. There are two classes of commands, configuration commands that configure a persistent association with a remote server or peer or reference clock, and auxiliary commands that specify environmental variables that control various related operations.

### Configuration Commands

The various modes are determined by the command keyword and the type of the required IP address. Addresses are classed by type as (s) a remote server or peer (IPv4 class A, B and C), (b) the broadcast address of a local interface, (m) a multicast address (IPv4 class D), or (r) a reference clock address (127.127.x.x). Note that only those options applicable to each command are listed below. Use of options not listed may not be caught as an error, but may result in some weird and even destructive behavior.

If the Basic Socket Interface Extensions for IPv6 (RFC-2553) is detected, support for the IPv6 address family is generated in addition to the default support of the IPv4 address family. In a few cases, including the reslist billboard generated by ntpdc, IPv6 addresses are automatically generated. IPv6 addresses can be identified by the presence of colons : in the address field. IPv6 addresses can be used almost everywhere where IPv4 addresses can be used, with the exception of reference clock addresses, which are always IPv4.

Note that in contexts where a host name is expected, a `-4` qualifier preceding the host name forces DNS resolution to the IPv4 namespace, while a `-6` qualifier forces DNS resolution to the IPv6 namespace. See IPv6 references for the equivalent classes for that address family.

`pool` `address`[`burst`][`iburst`][`version` `version`][`prefer`][`minpoll` `minpoll`][`maxpoll` `maxpoll`]
`server` `address`[`key` `key` `|` `Cm` `autokey`][`burst`][`iburst`][`version` `version`][`prefer`][`minpoll` `minpoll`][`maxpoll` `maxpoll`]
`peer` `address`[`key` `key` `|` `Cm` `autokey`][`version` `version`][`prefer`][`minpoll` `minpoll`][`maxpoll` `maxpoll`]
`broadcast` `address`[`key` `key` `|` `Cm` `autokey`][`version` `version`][`prefer`][`minpoll` `minpoll`][`ttl` `ttl`]
`manycastclient` `address`[`key` `key` `|` `Cm` `autokey`][`version` `version`][`prefer`][`minpoll` `minpoll`][`maxpoll` `maxpoll`][`ttl` `ttl`]

These five commands specify the time server name or address to be used and the mode in which to operate. The `address` can be either a DNS name or an IP address in dotted-quad notation. Additional information on association behavior can be found in the "Association Management" page (available as part of the HTML documentation provided in /usr/share/doc/ntp).

`pool`
  For type s addresses, this command mobilizes a persistent client mode association with a number of remote servers. In this mode the local clock can synchronized to the remote server, but the remote server can never be synchronized to the local clock.
`server`
  For type s and r addresses, this command mobilizes a persistent client mode association with the specified remote server or local radio clock. In this mode the local clock can synchronized to the remote server, but the remote server can never be synchronized to the local clock. This command should not be used for type b or m addresses.
`peer`
  For type s addresses (only), this command mobilizes a persistent symmetric-active mode association with the specified remote peer. In this mode the local clock can be synchronized to the remote peer or the remote peer can be synchronized to the local clock. This is useful in a network of servers where, depending on various failure scenarios, either the local or remote peer may be the better source of time. This command should NOT be used for type b, m or r addresses.
`broadcast`
  For type b and m addresses (only), this command mobilizes a persistent broadcast mode association. Multiple commands can be used to specify multiple local broadcast interfaces (subnets) and/or multiple multicast groups. Note that local broadcast messages go only to the interface associated with the subnet specified, but multicast messages go to all interfaces. In broadcast mode the local server sends periodic broadcast messages to a client population at the `address` specified, which is usually the broadcast address on (one of) the local network(s) or a multicast address assigned to NTP. The IANA has assigned the multicast group address IPv4 224.0.1.1 and IPv6 ff05::101 (site local) exclusively to NTP, but other nonconflicting addresses can be used to contain the messages within administrative boundaries. Ordinarily, this specification applies only to the local server operating as a sender; for operation as a broadcast client, see the `broadcastclient` or `multicastclient` commands below.
`manycastclient`
  For type m addresses (only), this command mobilizes a manycast client mode association for the multicast address specified. In this case a specific address must be supplied which matches the address used on the `manycastserver` command for the designated manycast servers. The NTP multicast address 224.0.1.1 assigned by the IANA should NOT be used, unless specific means are taken to avoid spraying large areas of the Internet with these messages and causing a possibly massive implosion of replies at the sender. The `manycastserver` command specifies that the local server is to operate in client mode with the remote servers that are discovered as the result of broadcast/multicast messages. The client broadcasts a request message to the group address associated with the specified `address` and specifically enabled servers respond to these messages. The client selects the servers providing the best time and continues as with the `server` command. The remaining servers are discarded as if never heard.

Options:

`autokey`
  All packets sent to and received from the server or peer are to include authentication fields encrypted using the autokey scheme described in Authentication Options.
`burst`
  when the server is reachable, send a burst of eight packets instead of the usual one. The packet spacing is normally 2 s; however, the spacing between the first and second packets can be changed with the calldelay command to allow additional time for a modem or ISDN call to complete. This is designed to improve timekeeping quality with the `server` command and s addresses.
`iburst`
  When the server is unreachable, send a burst of eight packets instead of the usual one. The packet spacing is normally 2 s; however, the spacing between the first two packets can be changed with the calldelay command to allow additional time for a modem or ISDN call to complete. This is designed to speed the initial synchronization acquisition with the `server` command and s addresses and when `ntpd(1ntpdmdoc)` is started with the `-q` option.
`key` `key`
  All packets sent to and received from the server or peer are to include authentication fields encrypted using the specified `key` identifier with values from 1 to 65534, inclusive. The default is to include no encryption field.
`minpoll` `minpoll`
`maxpoll` `maxpoll`
  These options specify the minimum and maximum poll intervals for NTP messages, as a power of 2 in seconds The maximum poll interval defaults to 10 (1,024 s), but can be increased by the `maxpoll` option to an upper limit of 17 (36.4 h). The minimum poll interval defaults to 6 (64 s), but can be decreased by the `minpoll` option to a lower limit of 4 (16 s).
`noselect`
  Marks the server as unused, except for display purposes. The server is discarded by the selection algroithm.
`prefer`
  Marks the server as preferred. All other things being equal, this host will be chosen for synchronization among a set of correctly operating hosts. See the "Mitigation Rules and the prefer Keyword" page (available as part of the HTML documentation provided in /usr/share/doc/ntp) for further information.
`ttl` `ttl`
  This option is used only with broadcast server and manycast client modes. It specifies the time-to-live `ttl` to use on broadcast server and multicast server and the maximum `ttl` for the expanding ring search with manycast client packets. Selection of the proper value, which defaults to 127, is something of a black art and should be coordinated with the network administrator.
`version` `version`
  Specifies the version number to be used for outgoing NTP packets. Versions 1-4 are the choices, with version 4 the default.

### Auxiliary Commands

`broadcastclient`
  This command enables reception of broadcast server messages to any local interface (type b) address. Upon receiving a message for the first time, the broadcast client measures the nominal server propagation delay using a brief client/server exchange with the server, then enters the broadcast client mode, in which it synchronizes to succeeding broadcast messages. Note that, in order to avoid accidental or malicious disruption in this mode, both the server and client should operate using symmetric-key or public-key authentication as described in Authentication Options.
`manycastserver` `address` `...`
  This command enables reception of manycast client messages to the multicast group address(es) (type m) specified. At least one address is required, but the NTP multicast address 224.0.1.1 assigned by the IANA should NOT be used, unless specific means are taken to limit the span of the reply and avoid a possibly massive implosion at the original sender. Note that, in order to avoid accidental or malicious disruption in this mode, both the server and client should operate using symmetric-key or public-key authentication as described in Authentication Options.
`multicastclient` `address` `...`
  This command enables reception of multicast server messages to the multicast group address(es) (type m) specified. Upon receiving a message for the first time, the multicast client measures the nominal server propagation delay using a brief client/server exchange with the server, then enters the broadcast client mode, in which it synchronizes to succeeding multicast messages. Note that, in order to avoid accidental or malicious disruption in this mode, both the server and client should operate using symmetric-key or public-key authentication as described in Authentication Options.

### Authentication Support

Authentication support allows the NTP client to verify that the server is in fact known and trusted and not an intruder intending accidentally or on purpose to masquerade as that server. The NTPv3 specification RFC-1305 defines a scheme which provides cryptographic authentication of received NTP packets. Originally, this was done using the Data Encryption Standard (DES) algorithm operating in Cipher Block Chaining (CBC) mode, commonly called DES-CBC. Subsequently, this was replaced by the RSA Message Digest 5 (MD5) algorithm using a private key, commonly called keyed-MD5. Either algorithm computes a message digest, or one-way hash, which can be used to verify the server has the correct private key and key identifier.

NTPv4 retains the NTPv3 scheme, properly described as symmetric key cryptography and, in addition, provides a new Autokey scheme based on public key cryptography. Public key cryptography is generally considered more secure than symmetric key cryptography, since the security is based on a private value which is generated by each server and never revealed. With Autokey all key distribution and management functions involve only public values, which considerably simplifies key distribution and storage. Public key management is based on X.509 certificates, which can be provided by commercial services or produced by utility programs in the OpenSSL software library or the NTPv4 distribution.

While the algorithms for symmetric key cryptography are included in the NTPv4 distribution, public key cryptography requires the OpenSSL software library to be installed before building the NTP distribution. Directions for doing that are on the Building and Installing the Distribution page.

Authentication is configured separately for each association using the `key` or `autokey` subcommand on the `peer`, `server`, `broadcast` and `manycastclient` configuration commands as described in Configuration Options page. The authentication options described below specify the locations of the key files, if other than default, which symmetric keys are trusted and the interval between various operations, if other than default.

Authentication is always enabled, although ineffective if not configured as described below. If a NTP packet arrives including a message authentication code (MAC), it is accepted only if it passes all cryptographic checks. The checks require correct key ID, key value and message digest. If the packet has been modified in any way or replayed by an intruder, it will fail one or more of these checks and be discarded. Furthermore, the Autokey scheme requires a preliminary protocol exchange to obtain the server certificate, verify its credentials and initialize the protocol

The `auth` flag controls whether new associations or remote configuration commands require cryptographic authentication. This flag can be set or reset by the `enable` and `disable` commands and also by remote configuration commands sent by a `ntpdc(1ntpdcmdoc)` program running in another machine. If this flag is enabled, which is the default case, new broadcast client and symmetric passive associations and remote configuration commands must be cryptographically authenticated using either symmetric key or public key cryptography. If this flag is disabled, these operations are effective even if not cryptographic authenticated. It should be understood that operating with the `auth` flag disabled invites a significant vulnerability where a rogue hacker can masquerade as a falseticker and seriously disrupt system timekeeping. It is important to note that this flag has no purpose other than to allow or disallow a new association in response to new broadcast and symmetric active messages and remote configuration commands and, in particular, the flag has no effect on the authentication process itself.

An attractive alternative where multicast support is available is manycast mode, in which clients periodically troll for servers as described in the Automatic NTP Configuration Options page. Either symmetric key or public key cryptographic authentication can be used in this mode. The principle advantage of manycast mode is that potential servers need not be configured in advance, since the client finds them during regular operation, and the configuration files for all clients can be identical.

The security model and protocol schemes for both symmetric key and public key cryptography are summarized below; further details are in the briefings, papers and reports at the NTP project page linked from `http://www.ntp.org/`.

### Symmetric-Key Cryptography

The original RFC-1305 specification allows any one of possibly 65,534 keys, each distinguished by a 32-bit key identifier, to authenticate an association. The servers and clients involved must agree on the key and key identifier to authenticate NTP packets. Keys and related information are specified in a key file, usually called ntp.keys, which must be distributed and stored using secure means beyond the scope of the NTP protocol itself. Besides the keys used for ordinary NTP associations, additional keys can be used as passwords for the `ntpq(1ntpqmdoc)` and `ntpdc(1ntpdcmdoc)` utility programs.

When `ntpd(1ntpdmdoc)` is first started, it reads the key file specified in the `keys` configuration command and installs the keys in the key cache. However, individual keys must be activated with the `trusted` command before use. This allows, for instance, the installation of possibly several batches of keys and then activating or deactivating each batch remotely using `ntpdc(1ntpdcmdoc)`. This also provides a revocation capability that can be used if a key becomes compromised. The `requestkey` command selects the key used as the password for the `ntpdc(1ntpdcmdoc)` utility, while the `controlkey` command selects the key used as the password for the `ntpq(1ntpqmdoc)` utility.

### Public Key Cryptography

NTPv4 supports the original NTPv3 symmetric key scheme described in RFC-1305 and in addition the Autokey protocol, which is based on public key cryptography. The Autokey Version 2 protocol described on the Autokey Protocol page verifies packet integrity using MD5 message digests and verifies the source with digital signatures and any of several digest/signature schemes. Optional identity schemes described on the Identity Schemes page and based on cryptographic challenge/response algorithms are also available. Using all of these schemes provides strong security against replay with or without modification, spoofing, masquerade and most forms of clogging attacks.

The Autokey protocol has several modes of operation corresponding to the various NTP modes supported. Most modes use a special cookie which can be computed independently by the client and server, but encrypted in transmission. All modes use in addition a variant of the S-KEY scheme, in which a pseudo-random key list is generated and used in reverse order. These schemes are described along with an executive summary, current status, briefing slides and reading list on the Autonomous Authentication page.

The specific cryptographic environment used by Autokey servers and clients is determined by a set of files and soft links generated by the `ntp-keygen(1ntpkeygenmdoc)` program. This includes a required host key file, required certificate file and optional sign key file, leapsecond file and identity scheme files. The digest/signature scheme is specified in the X.509 certificate along with the matching sign key. There are several schemes available in the OpenSSL software library, each identified by a specific string such as `md5WithRSAEncryption`, which stands for the MD5 message digest with RSA encryption scheme. The current NTP distribution supports all the schemes in the OpenSSL library, including those based on RSA and DSA digital signatures.

NTP secure groups can be used to define cryptographic compartments and security hierarchies. It is important that every host in the group be able to construct a certificate trail to one or more trusted hosts in the same group. Each group host runs the Autokey protocol to obtain the certificates for all hosts along the trail to one or more trusted hosts. This requires the configuration file in all hosts to be engineered so that, even under anticipated failure conditions, the NTP subnet will form such that every group host can find a trail to at least one trusted host.

### Naming and Addressing

It is important to note that Autokey does not use DNS to resolve addresses, since DNS can't be completely trusted until the name servers have synchronized clocks. The cryptographic name used by Autokey to bind the host identity credentials and cryptographic values must be independent of interface, network and any other naming convention. The name appears in the host certificate in either or both the subject and issuer fields, so protection against DNS compromise is essential.

By convention, the name of an Autokey host is the name returned by the Unix `gethostname(2)` system call or equivalent in other systems. By the system design model, there are no provisions to allow alternate names or aliases. However, this is not to say that DNS aliases, different names for each interface, etc., are constrained in any way.

It is also important to note that Autokey verifies authenticity using the host name, network address and public keys, all of which are bound together by the protocol specifically to deflect masquerade attacks. For this reason Autokey includes the source and destinatino IP addresses in message digest computations and so the same addresses must be available at both the server and client. For this reason operation with network address translation schemes is not possible. This reflects the intended robust security model where government and corporate NTP servers are operated outside firewall perimeters.

### Operation

A specific combination of authentication scheme (none, symmetric key, public key) and identity scheme is called a cryptotype, although not all combinations are compatible. There may be management configurations where the clients, servers and peers may not all support the same cryptotypes. A secure NTPv4 subnet can be configured in many ways while keeping in mind the principles explained above and in this section. Note however that some cryptotype combinations may successfully interoperate with each other, but may not represent good security practice.

The cryptotype of an association is determined at the time of mobilization, either at configuration time or some time later when a message of appropriate cryptotype arrives. When mobilized by a `server` or `peer` configuration command and no `key` or `autokey` subcommands are present, the association is not authenticated; if the `key` subcommand is present, the association is authenticated using the symmetric key ID specified; if the `autokey` subcommand is present, the association is authenticated using Autokey.

When multiple identity schemes are supported in the Autokey protocol, the first message exchange determines which one is used. The client request message contains bits corresponding to which schemes it has available. The server response message contains bits corresponding to which schemes it has available. Both server and client match the received bits with their own and select a common scheme.

Following the principle that time is a public value, a server responds to any client packet that matches its cryptotype capabilities. Thus, a server receiving an unauthenticated packet will respond with an unauthenticated packet, while the same server receiving a packet of a cryptotype it supports will respond with packets of that cryptotype. However, unconfigured broadcast or manycast client associations or symmetric passive associations will not be mobilized unless the server supports a cryptotype compatible with the first packet received. By default, unauthenticated associations will not be mobilized unless overridden in a decidedly dangerous way.

Some examples may help to reduce confusion. Client Alice has no specific cryptotype selected. Server Bob has both a symmetric key file and minimal Autokey files. Alice's unauthenticated messages arrive at Bob, who replies with unauthenticated messages. Cathy has a copy of Bob's symmetric key file and has selected key ID 4 in messages to Bob. Bob verifies the message with his key ID 4. If it's the same key and the message is verified, Bob sends Cathy a reply authenticated with that key. If verification fails, Bob sends Cathy a thing called a crypto-NAK, which tells her something broke. She can see the evidence using the `ntpq(1ntpqmdoc)` program.

Denise has rolled her own host key and certificate. She also uses one of the identity schemes as Bob. She sends the first Autokey message to Bob and they both dance the protocol authentication and identity steps. If all comes out okay, Denise and Bob continue as described above.

It should be clear from the above that Bob can support all the girls at the same time, as long as he has compatible authentication and identity credentials. Now, Bob can act just like the girls in his own choice of servers; he can run multiple configured associations with multiple different servers (or the same server, although that might not be useful). But, wise security policy might preclude some cryptotype combinations; for instance, running an identity scheme with one server and no authentication with another might not be wise.

### Key Management

The cryptographic values used by the Autokey protocol are incorporated as a set of files generated by the `ntp-keygen(1ntpkeygenmdoc)` utility program, including symmetric key, host key and public certificate files, as well as sign key, identity parameters and leapseconds files. Alternatively, host and sign keys and certificate files can be generated by the OpenSSL utilities and certificates can be imported from public certificate authorities. Note that symmetric keys are necessary for the `ntpq(1ntpqmdoc)` and `ntpdc(1ntpdcmdoc)` utility programs. The remaining files are necessary only for the Autokey protocol.

Certificates imported from OpenSSL or public certificate authorities have certian limitations. The certificate should be in ASN.1 syntax, X.509 Version 3 format and encoded in PEM, which is the same format used by OpenSSL. The overall length of the certificate encoded in ASN.1 must not exceed 1024 bytes. The subject distinguished name field (CN) is the fully qualified name of the host on which it is used; the remaining subject fields are ignored. The certificate extension fields must not contain either a subject key identifier or a issuer key identifier field; however, an extended key usage field for a trusted host must contain the value `trustRoot`;. Other extension fields are ignored.

### Authentication Commands

`autokey` [`logsec`]
  Specifies the interval between regenerations of the session key list used with the Autokey protocol. Note that the size of the key list for each association depends on this interval and the current poll interval. The default value is 12 (4096 s or about 1.1 hours). For poll intervals above the specified interval, a session key list with a single entry will be regenerated for every message sent.
`controlkey` `key`
  Specifies the key identifier to use with the `ntpq(1ntpqmdoc)` utility, which uses the standard protocol defined in RFC-1305. The `key` argument is the key identifier for a trusted key, where the value can be in the range 1 to 65,534, inclusive.
`crypto`[`cert` `file`][`leap` `file`][`randfile` `file`][`host` `file`][`sign` `file`][`gq` `file`][`gqpar` `file`][`iffpar` `file`][`mvpar` `file`][`pw` `password`]
  This command requires the OpenSSL library. It activates public key cryptography, selects the message digest and signature encryption scheme and loads the required private and public values described above. If one or more files are left unspecified, the default names are used as described above. Unless the complete path and name of the file are specified, the location of a file is relative to the keys directory specified in the `keysdir` command or default /usr/local/etc. Following are the subcommands:
  `cert` `file`
    Specifies the location of the required host public certificate file. This overrides the link ntpkey_cert_`hostname` in the keys directory.
  `gqpar` `file`
    Specifies the location of the optional GQ parameters file. This overrides the link ntpkey_gq_`hostname` in the keys directory.
  `host` `file`
    Specifies the location of the required host key file. This overrides the link ntpkey_key_`hostname` in the keys directory.
  `iffpar` `file`
    Specifies the location of the optional IFF parameters file.This overrides the link ntpkey_iff_`hostname` in the keys directory.
  `leap` `file`
    Specifies the location of the optional leapsecond file. This overrides the link ntpkey_leap in the keys directory.
  `mvpar` `file`
    Specifies the location of the optional MV parameters file. This overrides the link ntpkey_mv_`hostname` in the keys directory.
  `pw` `password`
    Specifies the password to decrypt files containing private keys and identity parameters. This is required only if these files have been encrypted.
  `randfile` `file`
    Specifies the location of the random seed file used by the OpenSSL library. The defaults are described in the main text above.
  `sign` `file`
    Specifies the location of the optional sign key file. This overrides the link ntpkey_sign_`hostname` in the keys directory. If this file is not found, the host key is also the sign key.
`keys` `keyfile`
  Specifies the complete path and location of the MD5 key file containing the keys and key identifiers used by `ntpd(1ntpdmdoc)`, `ntpq(1ntpqmdoc)` and `ntpdc(1ntpdcmdoc)` when operating with symmetric key cryptography. This is the same operation as the `-k` command line option.
`keysdir` `path`
  This command specifies the default directory path for cryptographic keys, parameters and certificates. The default is /usr/local/etc/.
`requestkey` `key`
  Specifies the key identifier to use with the `ntpdc(1ntpdcmdoc)` utility program, which uses a proprietary protocol specific to this implementation of `ntpd(1ntpdmdoc)`. The `key` argument is a key identifier for the trusted key, where the value can be in the range 1 to 65,534, inclusive.
`revoke` `logsec`
  Specifies the interval between re-randomization of certain cryptographic values used by the Autokey scheme, as a power of 2 in seconds. These values need to be updated frequently in order to deflect brute-force attacks on the algorithms of the scheme; however, updating some values is a relatively expensive operation. The default interval is 16 (65,536 s or about 18 hours). For poll intervals above the specified interval, the values will be updated for every message sent.
`trustedkey` `key` `...`
  Specifies the key identifiers which are trusted for the purposes of authenticating peers with symmetric key cryptography, as well as keys used by the `ntpq(1ntpqmdoc)` and `ntpdc(1ntpdcmdoc)` programs. The authentication procedures require that both the local and remote servers share the same key and key identifier for this purpose, although different keys can be used with different servers. The `key` arguments are 32-bit unsigned integers with values from 1 to 65,534.

### Error Codes

The following error codes are reported via the NTP control and monitoring protocol trap mechanism.

101
  (bad field format or length) The packet has invalid version, length or format.
102
  (bad timestamp) The packet timestamp is the same or older than the most recent received. This could be due to a replay or a server clock time step.
103
  (bad filestamp) The packet filestamp is the same or older than the most recent received. This could be due to a replay or a key file generation error.
104
  (bad or missing public key) The public key is missing, has incorrect format or is an unsupported type.
105
  (unsupported digest type) The server requires an unsupported digest/signature scheme.
106
  (mismatched digest types) Not used.
107
  (bad signature length) The signature length does not match the current public key.
108
  (signature not verified) The message fails the signature check. It could be bogus or signed by a different private key.
109
  (certificate not verified) The certificate is invalid or signed with the wrong key.
110
  (certificate not verified) The certificate is not yet valid or has expired or the signature could not be verified.
111
  (bad or missing cookie) The cookie is missing, corrupted or bogus.
112
  (bad or missing leapseconds table) The leapseconds table is missing, corrupted or bogus.
113
  (bad or missing certificate) The certificate is missing, corrupted or bogus.
114
  (bad or missing identity) The identity key is missing, corrupt or bogus.

### Monitoring Support

`ntpd(1ntpdmdoc)` includes a comprehensive monitoring facility suitable for continuous, long term recording of server and client timekeeping performance. See the `statistics` command below for a listing and example of each type of statistics currently supported. Statistic files are managed using file generation sets and scripts in the ./scripts directory of this distribution. Using these facilities and UNIX `cron(8)` jobs, the data can be automatically summarized and archived for retrospective analysis.

### Monitoring Commands

`statistics` `name` `...`
  Enables writing of statistics records. Currently, four kinds of `name` statistics are supported.
  `clockstats`
    Enables recording of clock driver statistics information. Each update received from a clock driver appends a line of the following form to the file generation set named `clockstats`:

                  49213 525.624 127.127.4.1 93 226 00:08:29.606 D

    The first two fields show the date (Modified Julian Day) and time (seconds and fraction past UTC midnight). The next field shows the clock address in dotted-quad notation. The final field shows the last timecode received from the clock in decoded ASCII format, where meaningful. In some clock drivers a good deal of additional information can be gathered and displayed as well. See information specific to each clock for further details.

  `cryptostats`
    This option requires the OpenSSL cryptographic software library. It enables recording of cryptographic public key protocol information. Each message received by the protocol module appends a line of the following form to the file generation set named `cryptostats`:

                  49213 525.624 127.127.4.1 message

    The first two fields show the date (Modified Julian Day) and time (seconds and fraction past UTC midnight). The next field shows the peer address in dotted-quad notation, The final message field includes the message type and certain ancillary information. See the Authentication Options section for further information.

  `loopstats`
    Enables recording of loop filter statistics information. Each update of the local clock outputs a line of the following form to the file generation set named `loopstats`:

                  50935 75440.031 0.000006019 13.778190 0.000351733 0.0133806

    The first two fields show the date (Modified Julian Day) and time (seconds and fraction past UTC midnight). The next five fields show time offset (seconds), frequency offset (parts per million - PPM), RMS jitter (seconds), Allan deviation (PPM) and clock discipline time constant.

  `peerstats`
    Enables recording of peer statistics information. This includes statistics records of all peers of a NTP server and of special signals, where present and configured. Each valid update appends a line of the following form to the current element of a file generation set named `peerstats`:

                  48773 10847.650 127.127.4.1 9714 -0.001605376 0.000000000 0.001424877 0.000958674

    The first two fields show the date (Modified Julian Day) and time (seconds and fraction past UTC midnight). The next two fields show the peer address in dotted-quad notation and status, respectively. The status field is encoded in hex in the format described in Appendix A of the NTP specification RFC 1305. The final four fields show the offset, delay, dispersion and RMS jitter, all in seconds.

  `rawstats`
    Enables recording of raw-timestamp statistics information. This includes statistics records of all peers of a NTP server and of special signals, where present and configured. Each NTP message received from a peer or clock driver appends a line of the following form to the file generation set named `rawstats`:

                  50928 2132.543 128.4.1.1 128.4.1.20 3102453281.584327000 3102453281.58622800031 02453332.540806000 3102453332.541458000

    The first two fields show the date (Modified Julian Day) and time (seconds and fraction past UTC midnight). The next two fields show the remote peer or clock address followed by the local address in dotted-quad notation. The final four fields show the originate, receive, transmit and final NTP timestamps in order. The timestamp values are as received and before processing by the various data smoothing and mitigation algorithms.

  `sysstats`
    Enables recording of ntpd statistics counters on a periodic basis. Each hour a line of the following form is appended to the file generation set named `sysstats`:

                  50928 2132.543 36000 81965 0 9546 56 71793 512 540 10 147

    The first two fields show the date (Modified Julian Day) and time (seconds and fraction past UTC midnight). The remaining ten fields show the statistics counter values accumulated since the last generated line.

    Time since restart `36000`
      Time in hours since the system was last rebooted.
    Packets received `81965`
      Total number of packets received.
    Packets processed `0`
      Number of packets received in response to previous packets sent
    Current version `9546`
      Number of packets matching the current NTP version.
    Previous version `56`
      Number of packets matching the previous NTP version.
    Bad version `71793`
      Number of packets matching neither NTP version.
    Access denied `512`
      Number of packets denied access for any reason.
    Bad length or format `540`
      Number of packets with invalid length, format or port number.
    Bad authentication `10`
      Number of packets not verified as authentic.
    Rate exceeded `147`
      Number of packets discarded due to rate limitation.
  `statsdir` `directory_path`
    Indicates the full path of a directory where statistics files should be created (see below). This keyword allows the (otherwise constant) `filegen` filename prefix to be modified for file generation sets, which is useful for handling statistics logs.
  `filegen` `name`
    [`file` `filename`] [`type` `typename`] [`link`|`nolink`] [`enable`|`disable`]

    Configures setting of generation file set name. Generation file sets provide a means for handling files that are continuously growing during the lifetime of a server. Server statistics are a typical example for such files. Generation file sets provide access to a set of files used to store the actual data. At any time at most one element of the set is being written to. The type given specifies when and how data will be directed to a new element of the set. This way, information stored in elements of a file set that are currently unused are available for administrational operations without the risk of disturbing the operation of ntpd. (Most important: they can be removed to free space for new data produced.)

    Note that this command can be sent from the `ntpdc(1ntpdcmdoc)` program running at a remote location.

    name This is the type of the statistics records, as shown in the `statistics` command. file`filename` This is the file name for the statistics records. Filenames of set members are built from three concatenated elements `Cm` `prefix`, `Cm` `filename` and `Cm` `suffix`:
    prefix This is a constant filename path. It is not subject to modifications via the `filegen` option. It is defined by the server, usually specified as a compile-time constant. It may, however, be configurable for individual file generation sets via other commands. For example, the prefix used with `loopstats` and `peerstats` generation can be configured using the `statsdir` option explained above. filename This string is directly concatenated to the prefix mentioned above (no intervening /). This can be modified using the file argument to the `filegen` statement. No .. elements are allowed in this component to prevent filenames referring to parts outside the filesystem hierarchy denoted by `prefix`. suffix This part is reflects individual elements of a file set. It is generated according to the type of a file set.
    type`typename` A file generation set is characterized by its type. The following types are supported:
    none The file set is actually a single plain file. pid One element of file set is used per incarnation of a ntpd server. This type does not perform any changes to file set members during runtime, however it provides an easy way of separating files belonging to different `ntpd(1ntpdmdoc)` server incarnations. The set member filename is built by appending a . to concatenated `prefix` and `filename` strings, and appending the decimal representation of the process ID of the `ntpd(1ntpdmdoc)` server process. day One file generation set element is created per day. A day is defined as the period between 00:00 and 24:00 UTC. The file set member suffix consists of a . and a day specification in the form `YYYYMMdd`. `YYYY` is a 4-digit year number (e.g., 1992). `MM` is a two digit month number. `dd` is a two digit day number. Thus, all information written at 10 December 1992 would end up in a file named `prefix` `filename` `Ns``.19921210`. week Any file set member contains data related to a certain week of a year. The term week is defined by computing day-of-year modulo 7. Elements of such a file generation set are distinguished by appending the following suffix to the file set filename base: A dot, a 4-digit year number, the letter `W`, and a 2-digit week number. For example, information from January, 10th 1992 would end up in a file with suffix No.`1992W1`. month One generation file set element is generated per month. The file name suffix consists of a dot, a 4-digit year number, and a 2-digit month. year One generation file element is generated per year. The filename suffix consists of a dot and a 4 digit year number. age This type of file generation sets changes to a new element of the file set every 24 hours of server operation. The filename suffix consists of a dot, the letter `a`, and an 8-digit number. This number is taken to be the number of seconds the server is running at the start of the corresponding 24-hour period. Information is only written to a file generation by specifying `enable`; output is prevented by specifying `disable`.
    link|`nolink` It is convenient to be able to access the current element of a file generation set by a fixed name. This feature is enabled by specifying `link` and disabled using `nolink`. If link is specified, a hard link from the current file set element to a file without suffix is created. When there is already a file with this name and the number of links of this file is one, it is renamed appending a dot, the letter `C`, and the pid of the ntpd server process. When the number of links is greater than one, the file is unlinked. This allows the current file to be accessed by a constant name. enable`|``Cm` `disable` Enables or disables the recording function.

### Access Control Support

The `ntpd(1ntpdmdoc)` daemon implements a general purpose address/mask based restriction list. The list contains address/match entries sorted first by increasing address values and and then by increasing mask values. A match occurs when the bitwise AND of the mask and the packet source address is equal to the bitwise AND of the mask and address in the list. The list is searched in order with the last match found defining the restriction flags associated with the entry. Additional information and examples can be found in the "NotesonConfiguringNTPandSettingupaNTPSubnet" page (available as part of the HTML documentation provided in /usr/share/doc/ntp).

The restriction facility was implemented in conformance with the access policies for the original NSFnet backbone time servers. Later the facility was expanded to deflect cryptographic and clogging attacks. While this facility may be useful for keeping unwanted or broken or malicious clients from congesting innocent servers, it should not be considered an alternative to the NTP authentication facilities. Source address based restrictions are easily circumvented by a determined cracker.

Clients can be denied service because they are explicitly included in the restrict list created by the restrict command or implicitly as the result of cryptographic or rate limit violations. Cryptographic violations include certificate or identity verification failure; rate limit violations generally result from defective NTP implementations that send packets at abusive rates. Some violations cause denied service only for the offending packet, others cause denied service for a timed period and others cause the denied service for an indefinate period. When a client or network is denied access for an indefinate period, the only way at present to remove the restrictions is by restarting the server.

### The Kiss-of-Death Packet

Ordinarily, packets denied service are simply dropped with no further action except incrementing statistics counters. Sometimes a more proactive response is needed, such as a server message that explicitly requests the client to stop sending and leave a message for the system operator. A special packet format has been created for this purpose called the "kiss-of-death" (KoD) packet. KoD packets have the leap bits set unsynchronized and stratum set to zero and the reference identifier field set to a four-byte ASCII code. If the `noserve` or `notrust` flag of the matching restrict list entry is set, the code is "DENY"; if the `limited` flag is set and the rate limit is exceeded, the code is "RATE". Finally, if a cryptographic violation occurs, the code is "CRYP".

A client receiving a KoD performs a set of sanity checks to minimize security exposure, then updates the stratum and reference identifier peer variables, sets the access denied (TEST4) bit in the peer flash variable and sends a message to the log. As long as the TEST4 bit is set, the client will send no further packets to the server. The only way at present to recover from this condition is to restart the protocol at both the client and server. This happens automatically at the client when the association times out. It will happen at the server only if the server operator cooperates.

### Access Control Commands

discard[`average` `avg`][`minimum` `min`][`monitor` `prob`] Set the parameters of the `limited` facility which protects the server from client abuse. The `average` subcommand specifies the minimum average packet spacing, while the `minimum` subcommand specifies the minimum packet spacing. Packets that violate these minima are discarded and a kiss-o'-death packet returned if enabled. The default minimum average and minimum are 5 and 2, respectively. The monitor subcommand specifies the probability of discard for packets that overflow the rate-control window. restrict`address`[`mask` `mask`][`flag``...`] The `address` argument expressed in dotted-quad form is the address of a host or network. Alternatively, the `address` argument can be a valid host DNS name. The `mask` argument expressed in dotted-quad form defaults to `255.255.255.255`, meaning that the `address` is treated as the address of an individual host. A default entry (address `0.0.0.0`, mask `0.0.0.0`) is always included and is always the first entry in the list. Note that text string `default`, with no mask option, may be used to indicate the default entry. In the current implementation, `flag` always restricts access, i.e., an entry with no flags indicates that free access to the server is to be given. The flags are not orthogonal, in that more restrictive flags will often make less restrictive ones redundant. The flags can generally be classed into two categories, those which restrict time service and those which restrict informational queries and attempts to do run-time reconfiguration of the server. One or more of the following flags may be specified: