SNTP client is included in the system package. RouterOS implements SNTP protocol defined in RFC4330. Manycast mode is not supported. NTP server and a NTP client is included in the separate ntp package, that is not installed by default.
Client configuration is located in the /system ntp client console path, and the "System > NTP Client" WinBox window. This configuration is shared by the SNTP client implementation in the system package and the NTP client implementation in the ntp package. When ntp package is installed and enabled, the SNTP client is disabled automatically.
|enabled (yes, no default: no)||enable SNTP client for time sychronisation|
|mode (broadcast,unciast , filed is read-only)||Mode that SNTP client will operate in. If no NTP servers are configured broadcast' mode will be used. If there is dynamic or static NTP server ip address or FQDN used it will automatically switch to unciast mode"|
|primary-ntp (IP address default: 0.0.0.0)|
IP address of NTP server that has to be used for time synchronization. If both values are non-zero, then SNTP client will alternate between the two server addresses, switching to the other when request to the current server times out or when the "KoD" packet is received, indicating that server is not willing to respond to requests from this client.
The following formats are accepted:
|secondary-ntp (IP address default: 0.0.0.0)||see primary-ntp|
|server-dns-names (Comma separated domain name list default: )||To set NTP server using its domain name. Domain name will be resolved each time NTP request is sent. Router has to have /ip dns configured.|
- active-server (IP address; read-only property) : Currently selected NTP server address. This value is equal to primary-ntp or secondary-ntp.
- poll-interval (Time interval; read-only property) : Current interval between requests sent to the active server. The initial value is 16 seconds, and it is increased by doubling to 15 minutes.
Last received packet information
Values of the following properties are reset when the SNTP client is stopped or restarted, either because of a configuration change, or because of a network error.
- last-update-from (IP address; read-only property) : Source IP address of the last received NTP server packed that was successfully processed.
- last-update-before (Time interval; read-only property) : Time since the last successfully received server message.
- last-adjustment (Time interval; read-only property) : Amount of clock adjustment that was calculated from the last successfully received NTP server message.
- last-bad-packet-from (IP address; read-only property) : Source IP address of last received SNTP packed that was not successfully processed. Reason of the failure and time since this packet was received is available in the next two properties.
- last-bad-packet-before (Time interval; read-only property) : Time since the last receive failure.
- last-bad-packet-reason (Text; read-only property) : Text that describes the reason of the last receive failure. Possible values are:
- bad-packet-length - Packet length is not in the acceptable range.
- server-not-synchronized - Leap Indicator field is set to "alarm condition" value, which means that clock on the server has not been synchronized yet.
- zero-transmit-timestamp - Transmit Timestamp field value is 0.
- bad-mode - Value of the Mode field is neither 'server' nor 'broadcast'.
- kod-ABCD - Received "KoD" (Kiss-o'-Death) response. ABCD is the short "kiss code" text from the Reference Identifier field.
- broadcast - Received proadcast message, but mode=unicast.
- non-broadcast - Received packed was server reply, but mode=broadcast.
- server-ip-mismatch - Received response from address that is not active-server.
- originate-timestamp-mismatch - Originate Timestamp field in the server response message is not the same as the one included in the last request.
- roundtrip-too-long - request/response roundtrip exceeded 1 second.
SNTP client can produce the following log messages. See article "log" on how to set up logging and how to inspect logs.
- ntp,debug gradually adjust by OFFS
- ntp,debug instantly adjust by OFFS
- ntp,debug Wait for N seconds before sending next message
- ntp,debug Wait for N seconds before restarting
- ntp,debug,packet packet receive error, restarting
- ntp,debug,packet received PKT
- ntp,debug,packet ignoring received PKT
- ntp,debug,packet error sending to IP, restarting
- ntp,debug,packet sending to IP PKT
Explanation of log message fields
- OFFS - difference of two NTP timestamp values, in hexadecimal.
- PKT - dump of NTP packet. If packet is shorter than the minimum 48 bytes, it is dumped as a hexadecimal string. Otherwise, packet is dumped as a list of field names and values, one per log line. Names of fields follow RFC4330.
- IP - remote IP address.
NOTE: the above logging rules work only with the built-in SNTP client, the separate NTP package doesn't have any logging facilities.
NTP client and server
To use NTP client and server, ntp package must be installed and enabled.
This applies only to RouterOS v6. RouterOS v7 main package includes client and server functionaly.
Client configuration is located in /system ntp client.
- enabled (yes or no; default value: no)
- mode (One of broadcast, unicast, multicast or manycast.)
- primary-ntp, secondary-ntp (IP address)
Server configuration is located in /system ntp server.
- enabled (yes or no; default value: no) - enable NTP server
- broadcast (yes or no; default value: no) - enable certain NTP server mode, for this mode to work you have to set up broadcast-addresses field
- multicast (yes or no; default value: no) - enable certain NTP server mode
- manycast (yes or no; default value: no) - enable certain NTP server mode
- broadcast-addresses (IP address; default value: ) - set broadcast address to use for NTP server broadcast mode
Set up NTP server for local network that is 192.168.88.0/24
/system ntp server set broadcast=yes broadcast-addresses=192.168.88.255 enabled=yes manycast=no