idnits 2.17.1 draft-ietf-ntp-mode-6-cmds-03.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == The document seems to contain a disclaimer for pre-RFC5378 work, but was first submitted on or after 10 November 2008. The disclaimer is usually necessary only for documents that revise or obsolete older RFCs, and that take significant amounts of text from those RFCs. If you can contact all authors of the source material and they are willing to grant the BCP78 rights to the IETF Trust, you can and should remove the disclaimer. Otherwise, the disclaimer is needed and you can ignore this comment. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (September 18, 2017) is 2405 days in the past. Is this intentional? Checking references for intended status: Informational ---------------------------------------------------------------------------- ** Obsolete normative reference: RFC 1305 (Obsoleted by RFC 5905) Summary: 1 error (**), 0 flaws (~~), 2 warnings (==), 1 comment (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group D. Mills 3 Internet-Draft University of Delaware 4 Intended status: Informational B. Haberman, Ed. 5 Expires: March 22, 2018 JHU 6 September 18, 2017 8 Control Messages Protocol for Use with Network Time Protocol Version 4 9 draft-ietf-ntp-mode-6-cmds-03 11 Abstract 13 This document describes the structure of the control messages used 14 with the Network Time Protocol. These control messages can be used 15 to monitor and control the Network Time Protocol application running 16 on any IP network attached computer. The information in this 17 document was originally described in Appendix B of RFC 1305. The 18 goal of this document is to provide a historic description of the 19 control messages. 21 Status of This Memo 23 This Internet-Draft is submitted in full conformance with the 24 provisions of BCP 78 and BCP 79. 26 Internet-Drafts are working documents of the Internet Engineering 27 Task Force (IETF). Note that other groups may also distribute 28 working documents as Internet-Drafts. The list of current Internet- 29 Drafts is at https://datatracker.ietf.org/drafts/current/. 31 Internet-Drafts are draft documents valid for a maximum of six months 32 and may be updated, replaced, or obsoleted by other documents at any 33 time. It is inappropriate to use Internet-Drafts as reference 34 material or to cite them other than as "work in progress." 36 This Internet-Draft will expire on March 22, 2018. 38 Copyright Notice 40 Copyright (c) 2017 IETF Trust and the persons identified as the 41 document authors. All rights reserved. 43 This document is subject to BCP 78 and the IETF Trust's Legal 44 Provisions Relating to IETF Documents 45 (https://trustee.ietf.org/license-info) in effect on the date of 46 publication of this document. Please review these documents 47 carefully, as they describe your rights and restrictions with respect 48 to this document. Code Components extracted from this document must 49 include Simplified BSD License text as described in Section 4.e of 50 the Trust Legal Provisions and are provided without warranty as 51 described in the Simplified BSD License. 53 This document may contain material from IETF Documents or IETF 54 Contributions published or made publicly available before November 55 10, 2008. The person(s) controlling the copyright in some of this 56 material may not have granted the IETF Trust the right to allow 57 modifications of such material outside the IETF Standards Process. 58 Without obtaining an adequate license from the person(s) controlling 59 the copyright in such materials, this document may not be modified 60 outside the IETF Standards Process, and derivative works of it may 61 not be created outside the IETF Standards Process, except to format 62 it for publication as an RFC or to translate it into languages other 63 than English. 65 Table of Contents 67 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 68 1.1. Control Message Overview . . . . . . . . . . . . . . . . 3 69 1.2. Remote Facility Message Overview . . . . . . . . . . . . 4 70 2. NTP Control Message Format . . . . . . . . . . . . . . . . . 4 71 3. Status Words . . . . . . . . . . . . . . . . . . . . . . . . 7 72 3.1. System Status Word . . . . . . . . . . . . . . . . . . . 8 73 3.2. Peer Status Word . . . . . . . . . . . . . . . . . . . . 10 74 3.3. Clock Status Word . . . . . . . . . . . . . . . . . . . . 12 75 3.4. Error Status Word . . . . . . . . . . . . . . . . . . . . 12 76 4. Commands . . . . . . . . . . . . . . . . . . . . . . . . . . 13 77 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 16 78 6. Security Considerations . . . . . . . . . . . . . . . . . . . 16 79 7. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 18 80 8. Normative References . . . . . . . . . . . . . . . . . . . . 18 81 Appendix A. NTP Remote Facility Message Format . . . . . . . . . 18 82 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 20 84 1. Introduction 86 RFC 1305 [RFC1305] described a set of control messages for use within 87 the Network Time Protocol (NTP) when a comprehensive network 88 management solution was not available. The definitions of these 89 control messages were not promulgated to RFC 5905 [RFC5905] when NTP 90 version 4 was documented. These messages were intended for use only 91 in systems where no other management facilities were available or 92 appropriate, such as in dedicated-function bus peripherals. Support 93 for these messages is not required in order to conform to RFC 5905 94 [RFC5905]. The control messages are described here as a historical 95 record given their use within NTPv4. 97 1.1. Control Message Overview 99 The NTP Control Message has the value 6 specified in the mode field 100 of the first octet of the NTP header and is formatted as shown in 101 Figure 1. The format of the data field is specific to each command 102 or response; however, in most cases the format is designed to be 103 constructed and viewed by humans and so is coded in free-form ASCII. 104 This facilitates the specification and implementation of simple 105 management tools in the absence of fully evolved network-management 106 facilities. As in ordinary NTP messages, the authenticator field 107 follows the data field. If the authenticator is used the data field 108 is zero-padded to a 32-bit boundary, but the padding bits are not 109 considered part of the data field and are not included in the field 110 count. 112 IP hosts are not required to reassemble datagrams larger than 576 113 octets; however, some commands or responses may involve more data 114 than will fit into a single datagram. Accordingly, a simple 115 reassembly feature is included in which each octet of the message 116 data is numbered starting with zero. As each fragment is transmitted 117 the number of its first octet is inserted in the offset field and the 118 number of octets is inserted in the count field. The more-data (M) 119 bit is set in all fragments except the last. 121 Most control functions involve sending a command and receiving a 122 response, perhaps involving several fragments. The sender chooses a 123 distinct, nonzero sequence number and sets the status field and R and 124 E bits to zero. The responder interprets the opcode and additional 125 information in the data field, updates the status field, sets the R 126 bit to one and returns the three 32-bit words of the header along 127 with additional information in the data field. In case of invalid 128 message format or contents the responder inserts a code in the status 129 field, sets the R and E bits to one and, optionally, inserts a 130 diagnostic message in the data field. 132 Some commands read or write system variables and peer variables for 133 an association identified in the command. Others read or write 134 variables associated with a radio clock or other device directly 135 connected to a source of primary synchronization information. To 136 identify which type of variable and association a 16-bit association 137 identifier is used. System variables are indicated by the identifier 138 zero. As each association is mobilized a unique, nonzero identifier 139 is created for it. These identifiers are used in a cyclic fashion, 140 so that the chance of using an old identifier which matches a newly 141 created association is remote. A management entity can request a 142 list of current identifiers and subsequently use them to read and 143 write variables for each association. An attempt to use an expired 144 identifier results in an exception response, following which the list 145 can be requested again. 147 Some exception events, such as when a peer becomes reachable or 148 unreachable, occur spontaneously and are not necessarily associated 149 with a command. An implementation may elect to save the event 150 information for later retrieval or to send an asynchronous response 151 (called a trap) or both. In case of a trap the IP address and port 152 number is determined by a previous command and the sequence field is 153 set as described below. Current status and summary information for 154 the latest exception event is returned in all normal responses. Bits 155 in the status field indicate whether an exception has occurred since 156 the last response and whether more than one exception has occurred. 158 Commands need not necessarily be sent by an NTP peer, so ordinary 159 access-control procedures may not apply; however, the optional mask/ 160 match mechanism suggested elsewhere in this document provides the 161 capability to control access by mode number, so this could be used to 162 limit access for control messages (mode 6) to selected address 163 ranges. 165 1.2. Remote Facility Message Overview 167 The original development of the NTP daemon included a remote facility 168 (ntpdc) for monitoring and configuration. This facility used mode 7 169 commands to communicate with the NTP daemon. This document 170 illustrates the mode 7 packet format only. The commands embedded in 171 the mode 7 messages are implementation specific and not standardized 172 in any way. The mode 7 message format is described in Appendix A. 174 2. NTP Control Message Format 176 The format of the NTP Control Message header, which immediately 177 follows the UDP header, is shown in Figure 1. Following is a 178 description of its fields. Bit positions marked as zero are reserved 179 and should always be transmitted as zero. 181 0 1 2 3 182 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 183 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 184 |LI | VN |Mode |R|E|M| OpCode | Sequence Number | 185 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 186 | Status | Association ID | 187 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 188 | Offset | Count | 189 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 190 | | 191 / Data (up to 468 bytes) / 192 | | 193 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 194 | Padding (optional) | 195 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 196 | | 197 / Authenticator (optional, 96 bits) / 198 | | 199 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 201 Figure 1: NTP Control Message Header 203 Leap Indicator (LI): This is a two-bit integer that is set to b00 for 204 control message requests and responses. The Leap Indicator value 205 used as this position in mot NTP modes is in the System Status Word 206 provided in some control message responses. 208 Version Number (VN): This is a three-bit integer indicating a minimum 209 NTP version number. NTP servers do not respond to control messages 210 with an unrecognized version number. Requests may intentionally use 211 a lower version number to enable interoperability with earlier 212 versions of NTP. Responses carry the same version as the 213 corresponding request. 215 Mode: This is a three-bit integer indicating the mode. The value 6 216 indicates an NTP control message. 218 Response Bit (R): Set to zero for commands, one for responses. 220 Error Bit (E): Set to zero for normal response, one for error 221 response. 223 More Bit (M): Set to zero for last fragment, one for all others. 225 Operation Code (OpCode): This is a five-bit integer specifying the 226 command function. Values currently defined include the following: 228 +-------+--------------------------------------------------+ 229 | Code | Meaning | 230 +-------+--------------------------------------------------+ 231 | 0 | reserved | 232 | 1 | read status command/response | 233 | 2 | read variables command/response | 234 | 3 | write variables command/response | 235 | 4 | read clock variables command/response | 236 | 5 | write clock variables command/response | 237 | 6 | set trap address/port command/response | 238 | 7 | trap response | 239 | 8 | runtime configuration command/response | 240 | 9 | export configuration to file command/response | 241 | 10 | retrieve remote address stats command/response | 242 | 11 | retrieve ordered list command/response | 243 | 12 | request client-specific nonce command/response | 244 | 13-30 | reserved | 245 | 31 | unset trap address/port command/response | 246 +-------+--------------------------------------------------+ 248 Sequence Number: This is a 16-bit integer indicating the sequence 249 number of the command or response. Each request uses a different 250 sequence number. Each response carries the same sequence number as 251 its corresponding request. For asynchronous trap responses, the 252 responder increments the sequence number by one for each response, 253 allowing trap receivers to detect missing trap responses. The 254 sequence number of each fragment of a multiple-datagram response 255 carries the same sequence number, copied from the request. 257 Status: This is a 16-bit code indicating the current status of the 258 system, peer or clock, with values coded as described in following 259 sections. 261 Association ID: This is a 16-bit unsigned integer identifying a valid 262 association, or zero for the system clock. 264 Offset: This is a 16-bit unsigned integer indicating the offset, in 265 octets, of the first octet in the data area. The offset is set to 266 zero in requests. Responses spanning multiple datagrams use a 267 positive offset in all but the first datagram. 269 Count: This is a 16-bit unsigned integer indicating the length of the 270 data field, in octets. 272 Data: This contains the message data for the command or response. 273 The maximum number of data octets is 468. 275 Padding (optional): Conains zero to three octets with value zero, as 276 needed to ensure the overall control message size is a multiple of 4 277 octets. 279 Authenticator (optional): When the NTP authentication mechanism is 280 implemented, this contains the authenticator information defined in 281 Appendix C of RFC 1305. 283 3. Status Words 285 Status words indicate the present status of the system, associations 286 and clock. They are designed to be interpreted by network-monitoring 287 programs and are in one of four 16-bit formats shown in Figure 2 and 288 described in this section. System and peer status words are 289 associated with responses for all commands except the read clock 290 variables, write clock variables and set trap address/port commands. 291 The association identifier zero specifies the system status word, 292 while a nonzero identifier specifies a particular peer association. 293 The status word returned in response to read clock variables and 294 write clock variables commands indicates the state of the clock 295 hardware and decoding software. A special error status word is used 296 to report malformed command fields or invalid values. 298 0 1 299 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 300 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 301 | LI| Clock Src | Count | Code | 302 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 303 System Status Word 305 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 306 | Status | SEL | Count | Code | 307 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 308 Peer Status Word 310 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 311 | Clock Status | Code | 312 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 313 Radio Status Word 315 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 316 | Error Code | Reserved | 317 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 318 Error Status Word 320 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 321 | Reserved | Count | Code | 322 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 323 Clock Status Word 325 Figure 2: Status Word Formats 327 3.1. System Status Word 329 The system status word appears in the status field of the response to 330 a read status or read variables command with a zero association 331 identifier. The format of the system status word is as follows: 333 Leap Indicator (LI): This is a two-bit code warning of an impending 334 leap second to be inserted/deleted in the last minute of the current 335 day, with bit 0 and bit 1, respectively, coded as follows: 337 +------+------------------------------------------------------------+ 338 | LI | Meaning | 339 +------+------------------------------------------------------------+ 340 | 00 | no warning | 341 | 01 | insert second after 23:59:59 of the current day | 342 | 10 | delete second 23:59:59 of the current day | 343 | 11 | unsynchronized | 344 +------+------------------------------------------------------------+ 345 Clock Source (Clock Src): This is a six-bit integer indicating the 346 current synchronization source, with values coded as follows: 348 +-------+-----------------------------------------------------------+ 349 | Code | Meaning | 350 +-------+-----------------------------------------------------------+ 351 | 0 | unspecified or unknown | 352 | 1 | Calibrated atomic clock (e.g., PPS, HP 5061) | 353 | 2 | VLF (band 4) or LF (band 5) radio (e.g., OMEGA,, WWVB) | 354 | 3 | HF (band 7) radio (e.g., CHU, MSF, WWV/H) | 355 | 4 | UHF (band 9) satellite (e.g., GOES, GPS) | 356 | 5 | local net (e.g., DCN, TSP, DTS) | 357 | 6 | UDP/NTP | 358 | 7 | UDP/TIME | 359 | 8 | eyeball-and-wristwatch | 360 | 9 | telephone modem (e.g., NIST) | 361 | 10-63 | reserved | 362 +-------+-----------------------------------------------------------+ 364 System Event Counter (Count): This is a four-bit integer indicating 365 the number of system events occurring since the last time the System 366 Event Code changed. Upon reaching 15, subsequent events with the 367 same code are not counted. 369 System Event Code (Code): This is a four-bit integer identifying the 370 latest system exception event, with new values overwriting previous 371 values, and coded as follows: 373 +------+---------------------------------------------------------+ 374 | Code | Meaning | 375 +------+---------------------------------------------------------+ 376 | 0 | unspecified | 377 | 1 | frequency correction (drift) file not available | 378 | 2 | frequency correction started (frequency stepped) | 379 | 3 | spike detected and ignored, starting stepout timer | 380 | 4 | frequency training started | 381 | 5 | clock synchronized | 382 | 6 | system restart | 383 | 7 | panic stop (required step greater than panic threshold) | 384 | 8 | no system peer | 385 | 9 | leap second insertion/deletion armed for the | 386 | | of the current month | 387 | 10 | leap second disarmed | 388 | 11 | leap second inserted or deleted | 389 | 12 | clock stepped (stepout timer expired) | 390 | 13 | kernel loop discipline status changed | 391 | 14 | leapseconds table loaded from file | 392 | 15 | leapseconds table outdated, updated file needed | 393 +------+---------------------------------------------------------+ 395 3.2. Peer Status Word 397 A peer status word is returned in the status field of a response to a 398 read status, read variables or write variables command and appears 399 also in the list of association identifiers and status words returned 400 by a read status command with a zero association identifier. The 401 format of a peer status word is as follows: 403 Peer Status (Status): This is a five-bit code indicating the status 404 of the peer determined by the packet procedure, with bits assigned as 405 follows: 407 +-------------+---------------------------------------------------+ 408 | Peer Status | Meaning | 409 +-------------+---------------------------------------------------+ 410 | 0 | configured (peer.config) | 411 | 1 | authentication enabled (peer.authenable) | 412 | 2 | authentication okay (peer.authentic) | 413 | 3 | reachability okay (peer.reach != 0) | 414 | 4 | broadcast association | 415 +-------------+---------------------------------------------------+ 417 Peer Selection (SEL): This is a three-bit integer indicating the 418 status of the peer determined by the clock-selection procedure, with 419 values coded as follows: 421 +-----+-------------------------------------------------------------+ 422 | Sel | Meaning | 423 +-----+-------------------------------------------------------------+ 424 | 0 | rejected | 425 | 1 | discarded by intersection algorithm | 426 | 2 | discarded bu table overflow (not currently used) | 427 | 3 | discarded by the cluster algorithm | 428 | 4 | included by the combine algorithm | 429 | 5 | backup source (with more than sys.maxclock survivors) | 430 | 6 | system peer (synchronization source) | 431 | 7 | PPS (pulse per second) peer | 432 +-----+-------------------------------------------------------------+ 434 Peer Event Counter (Count): This is a four-bit integer indicating the 435 number of peer exception events that occurred since the last time the 436 peer event code changed. Upon reaching 15, subsequent events with 437 the same code are not counted. 439 Peer Event Code (Code): This is a four-bit integer identifying the 440 latest peer exception event, with new values overwriting previous 441 values, and coded as follows: 443 +-------+--------------------------------------------------------+ 444 | Peer | | 445 | Event | Meaning | 446 | Code | | 447 +-------+--------------------------------------------------------+ 448 | 0 | unspecified | 449 | 1 | association mobilized | 450 | 2 | association demobilized | 451 | 3 | peer unreachable (peer.reach was nonzero now zero) | 452 | 4 | peer reachable (peer.reach was zero now nonzero) | 453 | 5 | association restarted or timed out | 454 | 6 | no reply (only used with one-shot ntpd -q) | 455 | 7 | peer rate limit exceeded (kiss code RATE received) | 456 | 8 | access denied (kiss code DENY received) | 457 | 9 | leap second insertion/deletion at month's end armed | 458 | | by peer vote | 459 | 10 | became system peer (sys.peer) | 460 | 11 | reference clock event (see clock status word) | 461 | 12 | authentication failed | 462 | 13 | popcorn spike suppressed by peer clock filter register | 463 | 14 | entering interleaved mode | 464 | 15 | recovered from interleave error | 465 +-------+--------------------------------------------------------+ 467 3.3. Clock Status Word 469 There are two ways a reference clock can be attached to a NTP service 470 host, as an dedicated device managed by the operating system and as a 471 synthetic peer managed by NTP. As in the read status command, the 472 association identifier is used to identify which one, zero for the 473 system clock and nonzero for a peer clock. Only one system clock is 474 supported by the protocol, although many peer clocks can be 475 supported. A system or peer clock status word appears in the status 476 field of the response to a read clock variables or write clock 477 variables command. This word can be considered an extension of the 478 system status word or the peer status word as appropriate. The 479 format of the clock status word is as follows: 481 Reserved: An eight-bit integer that is ignored by requesters and 482 zeroed by responders. 484 Count: This is a four-bit integer indicating the number of clock 485 events that occurred since the last time the clock event code 486 changed. Upon reaching 15, subsequent events with the same code are 487 not counted. 489 Clock Code (Code): This is a four-bit integer indicating the current 490 clock status, with values coded as follows: 492 +--------------+--------------------------------------------------+ 493 | Clock Status | Meaning | 494 +--------------+--------------------------------------------------+ 495 | 0 | clock operating within nominals | 496 | 1 | reply timeout | 497 | 2 | bad reply format | 498 | 3 | hardware or software fault | 499 | 4 | propagation failure | 500 | 5 | bad date format or value | 501 | 6 | bad time format or value | 502 | 7-15 | reserved | 503 +--------------+--------------------------------------------------+ 505 3.4. Error Status Word 507 An error status word is returned in the status field of an error 508 response as the result of invalid message format or contents. Its 509 presence is indicated when the E (error) bit is set along with the 510 response (R) bit in the response. It consists of an eight-bit 511 integer coded as follows: 513 +--------------+--------------------------------------------------+ 514 | Error Status | Meaning | 515 +--------------+--------------------------------------------------+ 516 | 0 | unspecified | 517 | 1 | authentication failure | 518 | 2 | invalid message length or format | 519 | 3 | invalid opcode | 520 | 4 | unknown association identifier | 521 | 5 | unknown variable name | 522 | 6 | invalid variable value | 523 | 7 | administratively prohibited | 524 | 8-255 | reserved | 525 +--------------+--------------------------------------------------+ 527 4. Commands 529 Commands consist of the header and optional data field shown in 530 Figure 2. When present, the data field contains a list of 531 identifiers or assignments in the form 532 <>[=<>],<>[=<>],... where 533 <> is the ASCII name of a system or peer variable 534 specified in RFC 5905 and <> is expressed as a decimal, 535 hexadecimal or string constant in the syntax of the C programming 536 language. Where no ambiguity exists, the <169>sys.<170> or 537 <169>peer.<170> prefixes can be suppressed. Whitespace (ASCII 538 nonprinting format effectors) can be added to improve readability for 539 simple monitoring programs that do not reformat the data field. 540 Internet addresses are represented as four octets in the form 541 [n.n.n.n], where n is in decimal notation and the brackets are 542 optional. Timestamps, including reference, originate, receive and 543 transmit values, as well as the logical clock, are represented in 544 units of seconds and fractions, preferably in hexadecimal notation, 545 while delay, offset, dispersion and distance values are represented 546 in units of milliseconds and fractions, preferably in decimal 547 notation. All other values are represented as-is, preferably in 548 decimal notation. 550 Implementations may define variables other than those described in 551 RFC 5905. Called extramural variables, these are distinguished by 552 the inclusion of some character type other than alphanumeric or 553 <169>.<170> in the name. For those commands that return a list of 554 assignments in the response data field, if the command data field is 555 empty, it is expected that all available variables defined in RFC 556 5905 will be included in the response. For the read commands, if the 557 command data field is nonempty, an implementation may choose to 558 process this field to individually select which variables are to be 559 returned. 561 Commands are interpreted as follows: 563 Read Status (1): The command data field is empty or contains a list 564 of identifiers separated by commas. The command operates in two ways 565 depending on the value of the association identifier. If this 566 identifier is nonzero, the response includes the peer identifier and 567 status word. Optionally, the response data field may contain other 568 information, such as described in the Read Variables command. If the 569 association identifier is zero, the response includes the system 570 identifier (0) and status word, while the data field contains a list 571 of binary-coded pairs <> <>, one 572 for each currently defined association. 574 Read Variables (2): The command data field is empty or contains a 575 list of identifiers separated by commas. If the association 576 identifier is nonzero, the response includes the requested peer 577 identifier and status word, while the data field contains a list of 578 peer variables and values as described above. If the association 579 identifier is zero, the data field contains a list of system 580 variables and values. If a peer has been selected as the 581 synchronization source, the response includes the peer identifier and 582 status word; otherwise, the response includes the system identifier 583 (0) and status word. 585 Write Variables (3): The command data field contains a list of 586 assignments as described above. The variables are updated as 587 indicated. The response is as described for the Read Variables 588 command. 590 Read Clock Variables (4): The command data field is empty or contains 591 a list of identifiers separated by commas. The association 592 identifier selects the system clock variables or peer clock variables 593 in the same way as in the Read Variables command. The response 594 includes the requested clock identifier and status word and the data 595 field contains a list of clock variables and values, including the 596 last timecode message received from the clock. 598 Write Clock Variables (5): The command data field contains a list of 599 assignments as described above. The clock variables are updated as 600 indicated. The response is as described for the Read Clock Variables 601 command. 603 Set Trap Address/Port (6): The command association identifier, status 604 and data fields are ignored. The address and port number for 605 subsequent trap messages are taken from the source address and port 606 of the control message itself. The initial trap counter for trap 607 response messages is taken from the sequence field of the command. 608 The response association identifier, status and data fields are not 609 significant. Implementations should include sanity timeouts which 610 prevent trap transmissions if the monitoring program does not renew 611 this information after a lengthy interval. 613 Trap Response (7): This message is sent when a system, peer or clock 614 exception event occurs. The opcode field is 7 and the R bit is set. 615 The trap counter is incremented by one for each trap sent and the 616 sequence field set to that value. The trap message is sent using the 617 IP address and port fields established by the set trap address/port 618 command. If a system trap the association identifier field is set to 619 zero and the status field contains the system status word. If a peer 620 trap the association identifier field is set to that peer and the 621 status field contains the peer status word. Optional ASCII-coded 622 information can be included in the data field. 624 Configure (8): The command data is parsed and applied as if supplied 625 in the daemon configuration file. The reference implementation 626 daemon requires authentication for this command. 628 Save Configuration (9): Write a snapshot of the current configuration 629 to the file name supplied as the command data. The reference 630 implementation daemon requires authentication for this command. 631 Further, the command is refused unless a directory in which to store 632 the resulting files has been explicitly configured by the operator. 634 Read MRU (10): Retrieves records of recently seen remote addresses 635 and associated statistics. Command data consists of name=value pairs 636 controlling the selection of records, as well as a requestor-specific 637 nonce previously retrieved using this command or opcode 12, Request 638 Nonce. The response consists of name=value pairs where some names 639 can appear multiple times using a dot followed by a zero-based index 640 to distinguish them, and to associate elements of the same record 641 with the same index. A new nonce is provided with each successful 642 response. 644 Read ordered list (11): Retrieves an ordered list. If the command 645 data is empty or the seven characters "ifstats" the associated 646 statistics, status and counters for each local address are returned. 647 If the command data is the characters "addr_restrictions" then the 648 set of IPv4 remote address restrictions followed by the set of IPv6 649 remote address restrictions (access control lists) are returned. 650 Other command data returns error code 5 (unknown variable name). 651 Similar to Read MRU, response information uses zero-based indexes as 652 part of the variable name preceding the equals sign and value, where 653 each index relates information for a single address or network. This 654 opcode requires authentication. 656 Request Nonce (12): Retrieves a 96-bit nonce specific to the 657 requesting remote address, which is valid for a limited period. 658 Command data is not used in the request. The nonce consists of a 659 64-bit NTP timestamp and 32 bits of hash derived from that timestamp, 660 the remote address, and salt known only to the server which varies 661 between daemon runs. The reference implementation honors nonces 662 which were issued less than 16 seconds prior. Regurgitation of the 663 nonce by a managment agent demonstrates to the server that the agent 664 can receive datagrams sent to the source address of the request, 665 making source address "spoofing" more difficult in a similar way as 666 TCP's three-way handshake. 668 Unset Trap (31): Removes the requesting remote address and port from 669 the list of trap receivers. Command data is not used in the request. 670 If the address and port are not in the list of trap receivers, the 671 error code is 4, bad association. 673 5. IANA Considerations 675 This document makes no request of IANA. 677 Note to RFC Editor: this section may be removed on publication as an 678 RFC. 680 6. Security Considerations 682 A number of security vulnerabilities have been identified with these 683 control messages. 685 NTP's control query interface allows reading and writing of system, 686 peer, and clock variables remotely from arbitrary IP addresses using 687 commands mentioned in Section 4. Traditionally, overwriting these 688 variables, but not reading them, requires authentication by default. 689 However, this document argues that an NTP host must authenticate all 690 control queries and not just ones that overwrite these variables. 691 Alternatively, the host can use a whitelist to explicitly list IP 692 addresses that are allowed to control query the clients. These 693 access controls are required for the following reasons: 695 o NTP as a Distributed Denial-of-Service (DDoS) vector. NTP timing 696 query and response packets (modes 1-2, 3-4, 5) are usually short 697 in size. However, some NTP control queries generate a very long 698 packet in response to a short query. As such, there is a history 699 of use of NTP's control queries, which exhibit such behavior, to 700 perform DDoS attacks. These off-path attacks exploit the large 701 size of NTP control queries to cause UDP-based amplification 702 attacks (e.g., mode 7 monlist command generates a very long packet 703 in response to a small query (CVE-2013-5211)). These attacks only 704 use NTP as a vector for DoS atacks on other protocols, but do not 705 affect the time service on the NTP host itself. 707 o Time-shifting attacks through information leakage/overwriting. 708 NTP hosts save important system and peer state variables. An off- 709 path attacker who can read these variables remotely can leverage 710 the information leaked by these control queries to perform time- 711 shifting and DoS attacks on NTP clients. These attacks do affect 712 time synchronization on the NTP hosts. For instance, 714 * In the client/server mode, the client stores its local time 715 when it sends the query to the server in its xmt peer variable. 716 This variable is used to perform TEST2 to non-cryptographically 717 authenticate the server, i.e., if the origin timestamp field in 718 the corresponding server response packet matches the xmt peer 719 variable, then the client accepts the packet. An off-path 720 attacker, with the ability to read this variable can easily 721 spoof server response packets for the client, which will pass 722 TEST2, and can deny service or shift time on the NTP client. 723 CVE-2015-8139 describes the specific attack. 725 * The client also stores its local time when the server response 726 is received in its rec peer variable. This variable is used 727 for authentication in interleaved-pivot mode. An off-path 728 attacker with the ability to read this state variable can 729 easily shift time on the client by passing this test. CVE- 730 2016-1548 describes the attack. 732 o Fast-Scanning. NTP mode 6 control messages are usually small UDP 733 packets. Fast-scanning tools like ZMap can be used to spray the 734 entire (potentially reachable) Internet with these messages within 735 hours to identify vulnerable hosts. To make things worse, these 736 attacks can be extremely low-rate, only requiring a control query 737 for reconnaissance and a spoofed response to shift time on 738 vulnerable clients. CVE-2016-1548 is one such example. 740 NTP best practices recommend configuring ntpd with the no-query 741 parameter. The no-query parameter blocks access to all remote 742 control queries. However, sometimes the nosts do not want to block 743 all queries and want to give access for certain control queries 744 remotely. This could be for the purpose of remote management and 745 configuration of the hosts in certain scenarios. Such hosts tend to 746 use firewalls or other middleboxes to blacklist certain queries 747 within the network. 749 Recent work (reference needed) shows that significantly fewer hosts 750 respond to mode 7 monlist queries as compared to other control 751 queries because it is a well-known and exploited control query. 753 These queries are likely blocked using blacklists on firewalls and 754 middleboxes rather than the no-query option on NTP hosts. The 755 remaining control queries that can be exploited likely remain out of 756 the blacklist because they are undocumented in the current NTP 757 specification [RFC5905]. 759 This document describes all of the mode 6 control queries allowed by 760 NTP and can help administrators make informed decisions on security 761 measures to protect NTP devices from harmful queries and likely make 762 those systems less vulnerable. 764 7. Acknowledgements 766 Tim Plunkett created the original version of this document. Aanchal 767 Malhotra provided the initial version of the Security Considerations 768 section. 770 Karen O'Donoghue, David Hart, Harlan Stenn, and Philip Chimento 771 deserve credit for portions of this document due to their earlier 772 efforts to document these commands. 774 8. Normative References 776 [RFC1305] Mills, D., "Network Time Protocol (Version 3) 777 Specification, Implementation and Analysis", RFC 1305, 778 DOI 10.17487/RFC1305, March 1992, 779 . 781 [RFC5905] Mills, D., Martin, J., Ed., Burbank, J., and W. Kasch, 782 "Network Time Protocol Version 4: Protocol and Algorithms 783 Specification", RFC 5905, DOI 10.17487/RFC5905, June 2010, 784 . 786 Appendix A. NTP Remote Facility Message Format 788 The format of the NTP Remote Facility Message header, which 789 immediately follows the UDP header, is shown in Figure 3. Following 790 is a description of its fields. Bit positions marked as zero are 791 reserved and should always be transmitted as zero. 793 0 1 2 3 794 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 795 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 796 |R|M| VN |Mode |A| Sequence | Implementation| Req Code | 797 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 798 | Err | Count | MBZ | Size | 799 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 800 | | 801 / Data (up to 500 bytes) / 802 | | 803 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 804 | Encryption KeyID (when A bit set) | 805 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 806 | | 807 / Message Authentication Code (when A bit set) / 808 | | 809 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 811 Figure 3: NTP Remote Facility Message Header 813 Response Bit (R) : Set to 0 if the packet is a request. Set to 1 if 814 the packet is a reponse. 816 More Bit (M) : Set to 0 if this is the last packet in a response, 817 otherwise set to 1 in responses requiring more then one packet. 819 Version Number (VN) : Set to the version number of the NTP daemon. 821 Mode : Set to 7 for Remote Facility messages. 823 Authenticated Bit (A) : If set to 1, this packet contains 824 authentication information. 826 Sequence : For a multi-packet response, this field contains the 827 sequence number of this packet. Packets in a multi-packet response 828 are numbered starting with 0. The More Bit is set to 1 for all 829 packets but the last. 831 Implementation : The version number of the implementation that 832 defined the request code used in this message. An implementation 833 number of 0 is used for a Request Code supported by all versions of 834 the NTP daemon. The value 255 is reserved for future extensions. 836 Request Code (Req Code) : An implementation-specific code which 837 specifies the operation being requested. A Request Code definition 838 includes the format and semantics of the data included in the packet. 840 Error (Err) : Set to 0 for a request. For a response, this field 841 contains an error code relating to the request. If the Error is non- 842 zero, the operation requested wasn't performed. 844 0 - no error 846 1 - incompatible implementation number 848 2 - unimplemented request code 850 3 - format error 852 4 - no data available 854 7 - authentication failure 856 Count : The number of data items in the packet. Range is 0 to 500. 858 Must Be Zero (MBZ) : A reserved field set to 0 in requests and 859 responses. 861 Size : The size of each data item in the packet. Range is 0 to 500. 863 Data : A variable-sized field containing request/response data. For 864 requests and responses, the size in octets must be greater than or 865 equal to the product of the number of data items (Count) and the size 866 of a data item (Size). For requests, the data area is exactly 40 867 octets in length. For responses, the data area will range from 0 to 868 500 octets, inclusive. 870 Encryption KeyID : A 32-bit unsigned integer used to designate the 871 key used for the Message Authentication Code. This field is included 872 only when the A bit is set to 1. 874 Message Authentication Code : An optional Message Authentication Code 875 defined by the version of the NTP daemon indicated in the 876 Implementation field. This field is included only when the A bit is 877 set to 1. 879 Authors' Addresses 881 Dr. David L. Mills 882 University of Delaware 884 Email: mills@udel.edu 885 Brian Haberman (editor) 886 JHU 888 Email: brian@innovationslab.net