Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / usr.sbin / ntp / doc / ntpq.8
1 .\"
2 .\" $FreeBSD: src/usr.sbin/ntp/doc/ntpq.8,v 1.3.2.9 2003/03/11 22:31:30 trhodes Exp $
3 .\" $DragonFly: src/usr.sbin/ntp/doc/Attic/ntpq.8,v 1.2 2003/06/17 04:29:58 dillon Exp $
4 .\"
5 .Dd January 7, 2000
6 .Dt NTPQ 8
7 .Os
8 .Sh NAME
9 .Nm ntpq
10 .Nd standard NTP query program
11 .Sh SYNOPSIS
12 .Nm
13 .Op Fl inp
14 .Op Fl c Ar command
15 .Op Ar host ...
16 .Sh DESCRIPTION
17 The
18 .Nm
19 utility is used to query NTP servers
20 which implement the recommended NTP mode 6 control message format
21 about current state and to request changes in that state.
22 The
23 program may be run either in interactive mode or controlled using
24 command line arguments.
25 Requests to read and write arbitrary
26 variables can be assembled, with raw and pretty-printed output
27 options being available.
28 The
29 .Nm
30 utility can also obtain and print a
31 list of peers in a common format by sending multiple queries to the
32 server.
33 .Pp
34 If one or more request options is included on the command line
35 when
36 .Nm
37 is executed, each of the requests will be sent
38 to the NTP servers running on each of the hosts given as command
39 line arguments, or on localhost by default.
40 If no request options
41 are given,
42 .Nm
43 will attempt to read commands from the
44 standard input and execute these on the NTP server running on the
45 first host given on the command line, again defaulting to localhost
46 when no other host is specified.
47 The
48 .Nm
49 utility will prompt for
50 commands if the standard input is a terminal device.
51 .Pp
52 The
53 .Nm
54 utility uses NTP mode 6 packets to communicate with the
55 NTP server, and hence can be used to query any compatible server on
56 the network which permits it.
57 Note that since NTP is a UDP protocol
58 this communication will be somewhat unreliable, especially over
59 large distances in terms of network topology.
60 The
61 .Nm
62 utility makes
63 one attempt to retransmit requests, and will time requests out if
64 the remote host is not heard from within a suitable timeout
65 time.
66 .Pp
67 For examples and usage, see the
68 .Qq "NTP Debugging Techniques"
69 page
70 (available as part of the HTML documentation
71 provided in
72 .Pa /usr/share/doc/ntp ) .
73 .Pp
74 The following options are available:
75 .Bl -tag -width indent
76 .It Fl c
77 The following argument is interpreted as an interactive format
78 command and is added to the list of commands to be executed on the
79 specified host(s).
80 Multiple
81 .Fl c
82 options may be given.
83 .It Fl i
84 Force
85 .Nm
86 to operate in interactive mode.
87 Prompts
88 will be written to the standard output and commands read from the
89 standard input.
90 .It Fl n
91 Output all host addresses in dotted-quad numeric format rather
92 than converting to the canonical host names.
93 .It Fl p
94 Print a list of the peers known to the server as well as a
95 summary of their state.
96 This is equivalent to the
97 .Ic peers
98 interactive command.
99 .El
100 .Pp
101 Specifying a
102 command line option other than
103 .Fl i
104 or
105 .Fl n
106 will
107 cause the specified query (queries) to be sent to the indicated
108 host(s) immediately.
109 Otherwise,
110 .Nm
111 will attempt to read
112 interactive format commands from the standard input.
113 .Ss "Internal Commands"
114 Interactive format commands consist of a keyword followed by zero
115 to four arguments.
116 Only enough characters of the full keyword to
117 uniquely identify the command need be typed.
118 The output of a
119 command is normally sent to the standard output, but optionally the
120 output of individual commands may be sent to a file by appending a
121 .Ql \&> ,
122 followed by a file name, to the command line.
123 A
124 number of interactive format commands are executed entirely within
125 the
126 .Nm
127 utility itself and do not result in NTP mode 6
128 requests being sent to a server.
129 These are described following.
130 .Bl -tag -width indent
131 .It Ic \&? Op Ar command_keyword
132 .It Ic help Op Ar command_keyword
133 A
134 .Ql \&?
135 by itself will print a list of all the command
136 keywords known to this incarnation of
137 .Nm .
138 A
139 .Ql \&?
140 followed by a command keyword will print function and usage
141 information about the command.
142 This command is probably a better
143 source of information about
144 .Nm
145 than this manual
146 page.
147 .It Xo Ic addvars
148 .Ar variable_name Ns Op = Ns Ar value ...
149 .Xc
150 .It Ic rmvars Ar variable_name ...
151 .It Ic clearvars
152 The data carried by NTP mode 6 messages consists of a list of
153 items of the form
154 .Ql variable_name=value ,
155 where the
156 .Ql =value
157 is ignored, and can be omitted,
158 in requests to the server to read variables.
159 The
160 .Nm
161 utility maintains an internal list in which data to be included in control
162 messages can be assembled, and sent using the
163 .Ic readlist
164 and
165 .Ic writelist
166 commands described below.
167 The
168 .Ic addvars
169 command allows variables and their optional values to be added to
170 the list.
171 If more than one variable is to be added, the list should
172 be comma-separated and not contain white space.
173 The
174 .Ic rmvars
175 command can be used to remove individual variables from the list,
176 while the
177 .Ic clearlist
178 command removes all variables from the
179 list.
180 .It Ic authenticate Cm yes | Cm no
181 Normally
182 .Nm
183 does not authenticate requests unless
184 they are write requests.
185 The command
186 .Ql authenticate yes
187 causes
188 .Nm
189 to send authentication with all requests it
190 makes.
191 Authenticated requests causes some servers to handle
192 requests slightly differently, and can occasionally melt the CPU in
193 fuzzballs if you turn authentication on before doing a
194 .Ic peer
195 display.
196 .It Ic cooked
197 Causes output from query commands to be "cooked", so that
198 variables which are recognized by
199 .Nm
200 will have their
201 values reformatted for human consumption.
202 Variables which
203 .Nm
204 thinks should have a decodable value but didn't are
205 marked with a trailing
206 .Ql \&?  .
207 .It Xo Ic debug
208 .Cm more |
209 .Cm less |
210 .Cm off
211 .Xc
212 Turns internal query program debugging on and off.
213 .It Ic delay Ar milliseconds
214 Specify a time interval to be added to timestamps included in
215 requests which require authentication.
216 This is used to enable
217 (unreliable) server reconfiguration over long delay network paths
218 or between machines whose clocks are unsynchronized.
219 Actually the
220 server does not now require timestamps in authenticated requests,
221 so this command may be obsolete.
222 .It Ic host Ar hostname
223 Set the host to which future queries will be sent.
224 Hostname may
225 be either a host name or a numeric address.
226 .It Ic hostnames Cm yes | Cm no
227 If
228 .Cm yes
229 is specified, host names are printed in
230 information displays.
231 If
232 .Cm no
233 is specified, numeric
234 addresses are printed instead.
235 The default is
236 .Cm yes ,
237 unless
238 modified using the command line
239 .Fl n
240 switch.
241 .It Ic keyid Ar keyid
242 This command allows the specification of a key number to be
243 used to authenticate configuration requests.
244 This must correspond
245 to a key number the server has been configured to use for this
246 purpose.
247 .It Xo Ic ntpversion
248 .Cm 1 |
249 .Cm 2 |
250 .Cm 3 |
251 .Cm 4
252 .Xc
253 Sets the NTP version number which
254 .Nm
255 claims in
256 packets.
257 Defaults to 3, Note that mode 6 control messages (and
258 modes, for that matter) didn't exist in NTP version 1.
259 There appear
260 to be no servers left which demand version 1.
261 .It Ic quit
262 Exit
263 .Nm .
264 .It Ic passwd
265 This command prompts you to type in a password (which will not
266 be echoed) which will be used to authenticate configuration
267 requests.
268 The password must correspond to the key configured for
269 use by the NTP server for this purpose if such requests are to be
270 successful.
271 .It Ic raw
272 Causes all output from query commands is printed as received
273 from the remote server.
274 The only formating/interpretation done on
275 the data is to transform nonascii data into a printable (but barely
276 understandable) form.
277 .It Ic timeout Ar milliseconds
278 Specify a timeout period for responses to server queries.
279 The
280 default is about 5000 milliseconds.
281 Note that since
282 .Nm
283 retries each query once after a timeout, the total waiting time for
284 a timeout will be twice the timeout value set.
285 .El
286 .Ss Control Message Commands
287 Each peer known to an NTP server has a 16 bit integer association
288 identifier assigned to it.
289 NTP control messages which carry peer
290 variables must identify the peer the values correspond to by
291 including its association ID.
292 An association ID of 0 is special,
293 and indicates the variables are system variables, whose names are
294 drawn from a separate name space.
295 .Pp
296 Control message commands result in one or more NTP mode 6
297 messages being sent to the server, and cause the data returned to
298 be printed in some format.
299 Most commands currently implemented send
300 a single message and expect a single response.
301 The current
302 exceptions are the peers command, which will send a preprogrammed
303 series of messages to obtain the data it needs, and the mreadlist
304 and mreadvar commands, which will iterate over a range of
305 associations.
306 .Bl -tag -width indent
307 .It Ic associations
308 Obtains and prints a list of association identifiers and peer
309 statuses for in-spec peers of the server being queried.
310 The list is
311 printed in columns.
312 The first of these is an index numbering the
313 associations from 1 for internal use, the second the actual
314 association identifier returned by the server and the third the
315 status word for the peer.
316 This is followed by a number of columns
317 containing data decoded from the status word.
318 See the peers command
319 for a decode of the
320 .Sq condition
321 field.
322 Note that the data
323 returned by the
324 .Ic associations
325 command is cached internally
326 in
327 .Nm .
328 The index is then of use when dealing with stupid
329 servers which use association identifiers which are hard for humans
330 to type, in that for any subsequent commands which require an
331 association identifier as an argument, the form of index may be
332 used as an alternative.
333 .It Xo Ic clockvar Op Ar assocID
334 .Oo
335 .Ar variable_name Ns Op = Ns Ar value ...
336 .Oc
337 .Ar ...
338 .Xc
339 .It Xo Ic cv Op Ar assocID
340 .Oo
341 .Ar variable_name Ns Op = Ns Ar value ...
342 .Oc
343 .Ar ...
344 .Xc
345 Requests that a list of the server's clock variables be sent.
346 Servers which have a radio clock or other external synchronization
347 will respond positively to this.
348 If the association identifier is
349 omitted or zero the request is for the variables of the
350 .Sq system clock
351 and will generally get a positive response from all
352 servers with a clock.
353 If the server treats clocks as pseudo-peers,
354 and hence can possibly have more than one clock connected at once,
355 referencing the appropriate peer association ID will show the
356 variables of a particular clock.
357 Omitting the variable list will
358 cause the server to return a default variable display.
359 .It Ic lassociations
360 Obtains and prints a list of association identifiers and peer
361 statuses for all associations for which the server is maintaining
362 state.
363 This command differs from the
364 .Ic associations
365 command
366 only for servers which retain state for out-of-spec client
367 associations (i.e., fuzzballs).
368 Such associations are normally
369 omitted from the display when the
370 .Ic associations
371 command is
372 used, but are included in the output of
373 .Ic lassociations .
374 .It Ic lpassociations
375 Print data for all associations, including out-of-spec client
376 associations, from the internally cached list of associations.
377 This
378 command differs from
379 .Ic passociations
380 only when dealing with
381 fuzzballs.
382 .It Ic lpeers
383 Like R peers, except a summary of all associations for which
384 the server is maintaining state is printed.
385 This can produce a much
386 longer list of peers from fuzzball servers.
387 .It Ic mreadlist Ar assocID Ar assocID
388 .It Ic mrl Ar assocID Ar assocID
389 Like the
390 .Ic readlist
391 command, except the query is done
392 for each of a range of (nonzero) association IDs.
393 This range is
394 determined from the association list cached by the most recent
395 .Ic associations
396 command.
397 .It Xo Ic mreadvar Ar assocID Ar assocID
398 .Oo
399 .Ar variable_name Ns Op = Ns Ar value ...
400 .Oc
401 .Xc
402 .It Xo Ic mrv Ar assocID Ar assocID
403 .Oo
404 .Ar variable_name Ns Op = Ns Ar value ...
405 .Oc
406 .Xc
407 Like the
408 .Ic readvar
409 command, except the query is done for
410 each of a range of (nonzero) association IDs.
411 This range is
412 determined from the association list cached by the most recent
413 .Ic associations
414 command.
415 .It Ic opeers
416 An old form of the
417 .Ic peers
418 command with the reference ID
419 replaced by the local interface address.
420 .It Ic passociations
421 Displays association data concerning in-spec peers from the
422 internally cached list of associations.
423 This command performs
424 identically to the
425 .Ic associations
426 except that it displays
427 the internally stored data rather than making a new query.
428 .It Ic peers
429 Obtains a current list peers of the server, along with a
430 summary of each peer's state.
431 Summary information includes the
432 address of the remote peer, the reference ID (0.0.0.0 if this is
433 unknown), the stratum of the remote peer, the type of the peer
434 (local, unicast, multicast or broadcast), when the last packet was
435 received, the polling interval, in seconds, the reachability
436 register, in octal, and the current estimated delay, offset and
437 dispersion of the peer, all in milliseconds.
438 The character in the left margin indicates the fate of this
439 peer in the clock selection process.
440 Following is a list of these
441 characters, the pigeon used in the
442 .Ic rv
443 command, and a short
444 explanation of the condition revealed.
445 .Bl -tag -width indent
446 .It space
447 .Pq reject
448 The peer is discarded as unreachable, synchronized to this
449 server (synch loop) or outrageous synchronization distance.
450 .It x
451 .Pq falsetick
452 The peer is discarded by the intersection algorithm as a
453 falseticker.
454 .It \&.
455 .Pq excess
456 The peer is discarded as not among the first ten peers sorted
457 by synchronization distance and so is probably a poor candidate for
458 further consideration.
459 .It \&-
460 .Pq outlyer
461 The peer is discarded by the clustering algorithm as an
462 outlyer.
463 .It \&+
464 .Pq candidate
465 The peer is a survivor and a candidate for the combining
466 algorithm.
467 .It \&#
468 .Pq selected
469 The peer is a survivor, but not among the first six peers
470 sorted by synchronization distance.
471 If the association is ephemeral,
472 it may be demobilized to conserve resources.
473 .It \&*
474 .Pq peer
475 The peer has been declared the system peer and lends its
476 variables to the system variables.
477 .It o
478 .Pq (pps.peer)
479 The peer has been declared the system peer and lends its
480 variables to the system variables.
481 However, the actual system
482 synchronization is derived from a pulse-per-second (PPS) signal,
483 either indirectly via the PPS reference clock driver or directly
484 via kernel interface.
485 .El
486 .El
487 .Pp
488 The
489 .Va flash
490 variable is a valuable debugging aid.
491 It
492 displays the results of the original sanity checks defined in the
493 NTP specification RFC-1305 and additional ones added in NTP Version
494 4.
495 There are eleven tests called
496 .Sy TEST1
497 through
498 .Sy TEST11 .
499 The tests are performed in a certain order
500 designed to gain maximum diagnostic information while protecting
501 against accidental or malicious errors.
502 The
503 .Va flash
504 variable
505 is first initialized to zero.
506 If after each set of tests one or
507 more bits are set, the packet is discarded.
508 .Pp
509 Tests
510 .Sy TEST4
511 and
512 .Sy TEST5
513 check the access
514 permissions and cryptographic message digest.
515 If any bits are set
516 after that, the packet is discarded.
517 Tests
518 .Sy TEST10
519 and
520 .Sy TEST11
521 check the authentication state using Autokey
522 public-key cryptography, as described in the
523 .Sx Authentication Options
524 section of
525 .Xr ntp.conf 5 .
526 If any bits are set
527 and the association has previously been marked reachable, the
528 packet is discarded; otherwise, the originate and receive
529 timestamps are saved, as required by the NTP protocol, and
530 processing continues.
531 .Pp
532 Tests
533 .Sy TEST1
534 through
535 .Sy TEST3
536 check the packet
537 timestamps from which the offset and delay are calculated.
538 If any
539 bits are set, the packet is discarded; otherwise, the packet header
540 variables are saved.
541 Tests
542 .Sy TEST6
543 through
544 .Sy TEST8
545 check the health of the server.
546 If any bits are set, the packet is
547 discarded; otherwise, the offset and delay relative to the server
548 are calculated and saved.
549 Test
550 .Sy TEST9
551 checks the health of
552 the association itself.
553 If any bits are set, the packet is
554 discarded; otherwise, the saved variables are passed to the clock
555 filter and mitigation algorithms.
556 .Pp
557 The
558 .Va flash
559 bits for each test read in increasing order
560 from the least significant bit are defined as follows.
561 .Bl -tag -width indent
562 .It Sy TEST1
563 Duplicate packet.
564 The packet is at best a casual retransmission
565 and at worst a malicious replay.
566 .It Sy TEST2
567 Bogus packet.
568 The packet is not a reply to a message previously
569 sent.
570 This can happen when the NTP daemon is restarted and before
571 somebody else notices.
572 .It Sy TEST3
573 Unsynchronized.
574 One or more timestamp fields are invalid.
575 This
576 normally happens when the first packet from a peer is
577 received.
578 .It Sy TEST4
579 Access is denied.
580 See the
581 .Qq "Access Control"
582 page.
583 .It Sy TEST5
584 Cryptographic authentication fails.
585 See the
586 .Sx Authentication Options
587 section of
588 .Xr ntp.conf 5 .
589 .It Sy TEST6
590 The server is unsynchronized.
591 Wind up its clock first.
592 .It Sy TEST7
593 The server stratum is at the maximum than 15.
594 It is probably
595 unsynchronized and its clock needs to be wound up.
596 .It Sy TEST8
597 Either the root delay or dispersion is greater than one second,
598 which is highly unlikely unless the peer is synchronized to
599 Mars.
600 .It Sy TEST9
601 Either the peer delay or dispersion is greater than one second,
602 which is highly unlikely unless the peer is on Mars.
603 .It Sy TEST10
604 The autokey protocol has detected an authentication failure.
605 See the
606 .Sx Authentication Options
607 section of
608 .Xr ntp.conf 5 .
609 .It Sy TEST11
610 The autokey protocol has not verified the server or peer is
611 authentic and has valid public key credentials.
612 See the
613 .Sx Authentication Options
614 section of
615 .Xr ntp.conf 5 .
616 .El
617 .Pp
618 Additional system variables used by the NTP Version 4 Autokey
619 support include the following:
620 .Bl -tag -width indent
621 .It Ic certificate Ar filestamp
622 Shows the NTP seconds when the certificate file was
623 created.
624 .It Ic hostname Ar host
625 Shows the name of the host as returned by the Unix
626 .Xr gethostname 3
627 library function.
628 .It Ic flags Ar hex
629 Shows the current flag bits, where the
630 .Ar hex
631 bits
632 are interpreted as follows:
633 .Bl -tag -width indent
634 .It 0x01
635 autokey enabled
636 .It 0x02
637 RSA public/private key files present
638 .It 0x04
639 PKI certificate file present
640 .It 0x08
641 Diffie-Hellman parameters file present
642 .It 0x10
643 NIST leapseconds table file present
644 .El
645 .It Ic leapseconds Ar filestamp
646 Shows the NTP seconds when the NIST leapseconds table file was
647 created.
648 .It Ic params Ar filestamp
649 Shows the NTP seconds when the Diffie-Hellman agreement
650 parameter file was created.
651 .It Ic publickey Ar filestamp
652 Shows the NTP seconds when the RSA public/private key files
653 were created.
654 .It Ic refresh Ar filestamp
655 Shows the NTP seconds when the public cryptographic values were
656 refreshed and signed.
657 .It Ic tai Ar offset
658 Shows the TAI-UTC offset in seconds obtained from the NIST
659 leapseconds table.
660 .El
661 .Pp
662 Additional peer variables used by the NTP Version 4 Autokey
663 support include the following:
664 .Bl -tag -width indent
665 .It Ic certificate Ar filestamp
666 Shows the NTP seconds when the certificate file was
667 created.
668 .It Ic flags Ar hex
669 Shows the current flag bits, where the
670 .Ar hex
671 bits are
672 interpreted as in the system variable of the same name.
673 The bits
674 are set in the first autokey message received from the server and
675 then reset as the associated data are obtained from the server and
676 stored.
677 .It Ic hcookie Ar hex
678 Shows the host cookie used in the key agreement algorithm.
679 .It Ic initkey Ar key
680 Shows the initial key used by the key list generator in the
681 autokey protocol.
682 .It Ic initsequence Ar index
683 Shows the initial index used by the key list generator in the
684 autokey protocol.
685 .It Ic pcookie Ar hex
686 Specifies the peer cookie used in the key agreement
687 algorithm.
688 .It Ic timestamp Ar time
689 Shows the NTP seconds when the last autokey key list was
690 generated and signed.
691 .It Ic pstatus Ar assocID
692 Sends a read status request to the server for the given
693 association.
694 The names and values of the peer variables returned
695 will be printed.
696 Note that the status word from the header is
697 displayed preceding the variables, both in hexadecimal and in
698 pidgeon English.
699 .It Ic readlist Ar assocID
700 .It Ic rl Ar assocID
701 Requests that the values of the variables in the internal
702 variable list be returned by the server.
703 If the association ID is
704 omitted or is 0 the variables are assumed to be system variables.
705 Otherwise they are treated as peer variables.
706 If the internal
707 variable list is empty a request is sent without data, which should
708 induce the remote server to return a default display.
709 .It Xo Ic readvar Ar assocID
710 .Ar variable_name Ns Op = Ns Ar value
711 .Ar ...
712 .Xc
713 .It Xo Ic rv Ar assocID
714 .Ar variable_name Ns Op = Ns Ar value
715 .Ar ...
716 .Xc
717 Requests that the values of the specified variables be returned
718 by the server by sending a read variables request.
719 If the
720 association ID is omitted or is given as zero the variables are
721 system variables, otherwise they are peer variables and the values
722 returned will be those of the corresponding peer.
723 Omitting the
724 variable list will send a request with no data which should induce
725 the server to return a default display.
726 .It Xo Ic writevar Ar assocID
727 .Ar variable_name Ns Op = Ns Ar value
728 .Ar ...
729 .Xc
730 Like the readvar request, except the specified variables are
731 written instead of read.
732 .It Ic writelist Op Ar assocID
733 Like the readlist request, except the internal list variables
734 are written instead of read.
735 .El
736 .Sh SEE ALSO
737 .Xr ntp.conf 5 ,
738 .Xr ntpd 8 ,
739 .Xr ntpdc 8
740 .Sh BUGS
741 The
742 .Ic peers
743 command is non-atomic and may occasionally result in
744 spurious error messages about invalid associations occurring and
745 terminating the command.
746 The timeout time is a fixed constant,
747 which means you wait a long time for timeouts since it assumes sort
748 of a worst case.
749 The program should improve the timeout estimate as
750 it sends queries to a particular host, but doesn't.