Initial import from FreeBSD RELENG_4:
[dragonfly.git] / usr.sbin / ntp / doc / ntpdc.8
1 .\"
2 .\" $FreeBSD: src/usr.sbin/ntp/doc/ntpdc.8,v 1.2.2.8 2003/03/11 22:31:29 trhodes Exp $
3 .\"
4 .Dd January 7, 2000
5 .Dt NTPDC 8
6 .Os
7 .Sh NAME
8 .Nm ntpdc
9 .Nd special NTP query program
10 .Sh SYNOPSIS
11 .Nm
12 .Op Fl ilnps
13 .Op Fl c Ar command
14 .Op Ar host ...
15 .Sh DESCRIPTION
16 The
17 .Nm
18 utility is used to query the
19 .Xr ntpd 8
20 daemon about its
21 current state and to request changes in that state.
22 The program may
23 be run either in interactive mode or controlled using command line
24 arguments.
25 Extensive state and statistics information is available
26 through the
27 .Nm
28 interface.
29 In addition, nearly all the
30 configuration options which can be specified at startup using
31 ntpd's configuration file may also be specified at run time using
32 .Nm .
33 .Pp
34 The following options are available:
35 .Bl -tag -width indent
36 .It Fl c Ar command
37 The following argument is interpreted as an interactive format
38 command and is added to the list of commands to be executed on the
39 specified host(s).
40 Multiple
41 .Fl c
42 options may be given.
43 .It Fl i
44 Force
45 .Nm
46 to operate in interactive mode.
47 Prompts
48 will be written to the standard output and commands read from the
49 standard input.
50 .It Fl l
51 Obtain a list of peers which are known to the server(s).
52 This
53 switch is equivalent to
54 .Ql -c listpeers .
55 .It Fl n
56 Output all host addresses in dotted-quad numeric format rather
57 than converting to the canonical host names.
58 .It Fl p
59 Print a list of the peers known to the server as well as a
60 summary of their state.
61 This is equivalent to
62 .Ql -c peers .
63 .It Fl s
64 Print a list of the peers known to the server as well as a
65 summary of their state, but in a slightly different format than the
66 .Fl p
67 switch.
68 This is equivalent to
69 .Ql -c dmpeers .
70 .El
71 .Pp
72 If one or more request options are included on the command line
73 when
74 .Nm
75 is executed, each of the requests will be sent
76 to the NTP servers running on each of the hosts given as command
77 line arguments, or on localhost by default.
78 If no request options
79 are given,
80 .Nm
81 will attempt to read commands from the
82 standard input and execute these on the NTP server running on the
83 first host given on the command line, again defaulting to localhost
84 when no other host is specified.
85 The
86 .Nm
87 utility will prompt for
88 commands if the standard input is a terminal device.
89 .Pp
90 The
91 .Nm
92 utility uses NTP mode 7 packets to communicate with the
93 NTP server, and hence can be used to query any compatible server on
94 the network which permits it.
95 Note that since NTP is a UDP protocol
96 this communication will be somewhat unreliable, especially over
97 large distances in terms of network topology.
98 The
99 .Nm
100 utility makes
101 no attempt to retransmit requests, and will time requests out if
102 the remote host is not heard from within a suitable timeout
103 time.
104 .Pp
105 The operation of
106 .Nm
107 are specific to the particular
108 implementation of the
109 .Xr ntpd 8
110 daemon and can be expected to
111 work only with this and maybe some previous versions of the daemon.
112 Requests from a remote
113 .Nm
114 utility which affect the
115 state of the local server must be authenticated, which requires
116 both the remote program and local server share a common key and key
117 identifier.
118 Specifying a command line option other than
119 .Fl i
120 or
121 .Fl n
122 will cause the specified query (queries) to be sent to
123 the indicated host(s) immediately.
124 Otherwise,
125 .Nm
126 will
127 attempt to read interactive format commands from the standard
128 input.
129 .Ss "Interactive Commands"
130 Interactive format commands consist of a keyword followed by zero
131 to four arguments.
132 Only enough characters of the full keyword to
133 uniquely identify the command need be typed.
134 The output of a
135 command is normally sent to the standard output, but optionally the
136 output of individual commands may be sent to a file by appending a
137 .Ql \&> ,
138 followed by a file name, to the command line.
139 .Pp
140 A number of interactive format commands are executed entirely
141 within the
142 .Nm
143 utility itself and do not result in NTP
144 mode 7 requests being sent to a server.
145 These are described
146 following.
147 .Bl -tag -width indent
148 .It Ic \&? Ar command_keyword
149 .It Ic help Ar command_keyword
150 A
151 .Ic \&?
152 will print a list of all the command
153 keywords known to this incarnation of
154 .Nm .
155 A
156 .Ic \&?
157 followed by a command keyword will print function and usage
158 information about the command.
159 This command is probably a better
160 source of information about
161 .Xr ntpq 8
162 than this manual
163 page.
164 .It Ic delay Ar milliseconds
165 Specify a time interval to be added to timestamps included in
166 requests which require authentication.
167 This is used to enable
168 (unreliable) server reconfiguration over long delay network paths
169 or between machines whose clocks are unsynchronized.
170 Actually the
171 server does not now require timestamps in authenticated requests,
172 so this command may be obsolete.
173 .It Ic host Ar hostname
174 Set the host to which future queries will be sent.
175 Hostname may
176 be either a host name or a numeric address.
177 .It Ic hostnames Op Cm yes | Cm no
178 If
179 .Cm yes
180 is specified, host names are printed in
181 information displays.
182 If
183 .Cm no
184 is specified, numeric
185 addresses are printed instead.
186 The default is
187 .Cm yes ,
188 unless
189 modified using the command line
190 .Fl n
191 switch.
192 .It Ic keyid Ar keyid
193 This command allows the specification of a key number to be
194 used to authenticate configuration requests.
195 This must correspond
196 to a key number the server has been configured to use for this
197 purpose.
198 .It Ic quit
199 Exit
200 .Nm .
201 .It Ic passwd
202 This command prompts you to type in a password (which will not
203 be echoed) which will be used to authenticate configuration
204 requests.
205 The password must correspond to the key configured for
206 use by the NTP server for this purpose if such requests are to be
207 successful.
208 .It Ic timeout Ar milliseconds
209 Specify a timeout period for responses to server queries.
210 The
211 default is about 8000 milliseconds.
212 Note that since
213 .Nm
214 retries each query once after a timeout, the total waiting time for
215 a timeout will be twice the timeout value set.
216 .El
217 .Ss "Control Message Commands"
218 Query commands result in NTP mode 7 packets containing requests for
219 information being sent to the server.
220 These are read-only commands
221 in that they make no modification of the server configuration
222 state.
223 .Bl -tag -width indent
224 .It Ic listpeers
225 Obtains and prints a brief list of the peers for which the
226 server is maintaining state.
227 These should include all configured
228 peer associations as well as those peers whose stratum is such that
229 they are considered by the server to be possible future
230 synchonization candidates.
231 .It Ic peers
232 Obtains a list of peers for which the server is maintaining
233 state, along with a summary of that state.
234 Summary information
235 includes the address of the remote peer, the local interface
236 address (0.0.0.0 if a local address has yet to be determined), the
237 stratum of the remote peer (a stratum of 16 indicates the remote
238 peer is unsynchronized), the polling interval, in seconds, the
239 reachability register, in octal, and the current estimated delay,
240 offset and dispersion of the peer, all in seconds.
241 .Pp
242 The character in the left margin indicates the mode this peer
243 entry is operating in.
244 A
245 .Ql \&+
246 denotes symmetric active, a
247 .Ql \&-
248 indicates symmetric passive, a
249 .Ql \&=
250 means the
251 remote server is being polled in client mode, a
252 .Ql \&^
253 indicates that the server is broadcasting to this address, a
254 .Ql \&~
255 denotes that the remote peer is sending broadcasts and a
256 .Ql \&*
257 marks the peer the server is currently synchronizing
258 to.
259 .Pp
260 The contents of the host field may be one of four forms.
261 It may
262 be a host name, an IP address, a reference clock implementation
263 name with its parameter or
264 .Fn REFCLK "implementation_number" "parameter" .
265 On
266 .Ic hostnames
267 .Cm no
268 only IP-addresses
269 will be displayed.
270 .It Ic dmpeers
271 A slightly different peer summary list.
272 Identical to the output
273 of the
274 .Ic peers
275 command, except for the character in the
276 leftmost column.
277 Characters only appear beside peers which were
278 included in the final stage of the clock selection algorithm.
279 A
280 .Ql \&.
281 indicates that this peer was cast off in the falseticker
282 detection, while a
283 .Ql \&+
284 indicates that the peer made it
285 through.
286 A
287 .Ql \&*
288 denotes the peer the server is currently
289 synchronizing with.
290 .It Ic showpeer Ar peer_address ...
291 Shows a detailed display of the current peer variables for one
292 or more peers.
293 Most of these values are described in the NTP
294 Version 2 specification.
295 .It Ic pstats Ar peer_address ...
296 Show per-peer statistic counters associated with the specified
297 peer(s).
298 .It Ic clockinfo Ar clock_peer_address ...
299 Obtain and print information concerning a peer clock.
300 The
301 values obtained provide information on the setting of fudge factors
302 and other clock performance information.
303 .It Ic kerninfo
304 Obtain and print kernel phase-lock loop operating parameters.
305 This information is available only if the kernel has been specially
306 modified for a precision timekeeping function.
307 .It Ic loopinfo Op Cm oneline | Cm multiline
308 Print the values of selected loop filter variables.
309 The loop
310 filter is the part of NTP which deals with adjusting the local
311 system clock.
312 The
313 .Sq offset
314 is the last offset given to the
315 loop filter by the packet processing code.
316 The
317 .Sq frequency
318 is the frequency error of the local clock in parts-per-million
319 (ppm).
320 The
321 .Sq time_const
322 controls the stiffness of the
323 phase-lock loop and thus the speed at which it can adapt to
324 oscillator drift.
325 The
326 .Sq watchdog timer
327 value is the number
328 of seconds which have elapsed since the last sample offset was
329 given to the loop filter.
330 The
331 .Cm oneline
332 and
333 .Cm multiline
334 options specify the format in which this
335 information is to be printed, with
336 .Cm multiline
337 as the
338 default.
339 .It Ic sysinfo
340 Print a variety of system state variables, i.e., state related
341 to the local server.
342 All except the last four lines are described
343 in the NTP Version 3 specification, RFC-1305.
344 .Pp
345 The
346 .Sq system flags
347 show various system flags, some of
348 which can be set and cleared by the
349 .Ic enable
350 and
351 .Ic disable
352 configuration commands, respectively.
353 These are
354 the
355 .Cm auth  ,
356 .Cm bclient ,
357 .Cm monitor ,
358 .Cm pll ,
359 .Cm pps
360 and
361 .Cm stats
362 flags.
363 See the
364 .Xr ntpd 8
365 documentation for the meaning of these flags.
366 There
367 are two additional flags which are read only, the
368 .Cm kernel_pll
369 and
370 .Cm kernel_pps .
371 These flags indicate
372 the synchronization status when the precision time kernel
373 modifications are in use.
374 The
375 .Sq kernel_pll
376 indicates that
377 the local clock is being disciplined by the kernel, while the
378 .Sq kernel_pps
379 indicates the kernel discipline is provided by the PPS
380 signal.
381 .Pp
382 The
383 .Sq stability
384 is the residual frequency error remaining
385 after the system frequency correction is applied and is intended for
386 maintenance and debugging.
387 In most architectures, this value will
388 initially decrease from as high as 500 ppm to a nominal value in
389 the range .01 to 0.1 ppm.
390 If it remains high for some time after
391 starting the daemon, something may be wrong with the local clock,
392 or the value of the kernel variable
393 .Va kern.clockrate.tick
394 may be
395 incorrect.
396 .Pp
397 The
398 .Sq broadcastdelay
399 shows the default broadcast delay,
400 as set by the
401 .Ic broadcastdelay
402 configuration command.
403 .Pp
404 The
405 .Sq authdelay
406 shows the default authentication delay,
407 as set by the
408 .Ic authdelay
409 configuration command.
410 .It Ic sysstats
411 Print statistics counters maintained in the protocol
412 module.
413 .It Ic memstats
414 Print statistics counters related to memory allocation
415 code.
416 .It Ic iostats
417 Print statistics counters maintained in the input-output
418 module.
419 .It Ic timerstats
420 Print statistics counters maintained in the timer/event queue
421 support code.
422 .It Ic reslist
423 Obtain and print the server's restriction list.
424 This list is
425 (usually) printed in sorted order and may help to understand how
426 the restrictions are applied.
427 .It Ic monlist Op Ar version
428 Obtain and print traffic counts collected and maintained by the
429 monitor facility.
430 The version number should not normally need to be
431 specified.
432 .It Ic clkbug Ar clock_peer_address ...
433 Obtain debugging information for a reference clock driver.
434 This
435 information is provided only by some clock drivers and is mostly
436 undecodable without a copy of the driver source in hand.
437 .El
438 .Ss "Runtime Configuration Requests"
439 All requests which cause state changes in the server are
440 authenticated by the server using a configured NTP key (the
441 facility can also be disabled by the server by not configuring a
442 key).
443 The key number and the corresponding key must also be made
444 known to
445 .Nm .
446 This can be done using the
447 .Ic keyid
448 and
449 .Ic passwd
450 commands, the latter of which will prompt at the terminal for a
451 password to use as the encryption key.
452 You will also be prompted
453 automatically for both the key number and password the first time a
454 command which would result in an authenticated request to the
455 server is given.
456 Authentication not only provides verification that
457 the requester has permission to make such changes, but also gives
458 an extra degree of protection again transmission errors.
459 .Pp
460 Authenticated requests always include a timestamp in the packet
461 data, which is included in the computation of the authentication
462 code.
463 This timestamp is compared by the server to its receive time
464 stamp.
465 If they differ by more than a small amount the request is
466 rejected.
467 This is done for two reasons.
468 First, it makes simple
469 replay attacks on the server, by someone who might be able to
470 overhear traffic on your LAN, much more difficult.
471 Second, it makes
472 it more difficult to request configuration changes to your server
473 from topologically remote hosts.
474 While the reconfiguration facility
475 will work well with a server on the local host, and may work
476 adequately between time-synchronized hosts on the same LAN, it will
477 work very poorly for more distant hosts.
478 As such, if reasonable
479 passwords are chosen, care is taken in the distribution and
480 protection of keys and appropriate source address restrictions are
481 applied, the run time reconfiguration facility should provide an
482 adequate level of security.
483 .Pp
484 The following commands all make authenticated requests.
485 .Bl -tag -width indent
486 .It Xo Ic addpeer Ar peer_address
487 .Op Ar keyid
488 .Op Ar version
489 .Op Cm prefer
490 .Xc
491 Add a configured peer association at the given address and
492 operating in symmetric active mode.
493 Note that an existing
494 association with the same peer may be deleted when this command is
495 executed, or may simply be converted to conform to the new
496 configuration, as appropriate.
497 If the optional
498 .Ar keyid
499 is a
500 nonzero integer, all outgoing packets to the remote server will
501 have an authentication field attached encrypted with this key.
502 If
503 the value is 0 (or not given) no authentication will be done.
504 The
505 .Ar version
506 can be 1, 2 or 3 and defaults to 3.
507 The
508 .Cm prefer
509 keyword indicates a preferred peer (and thus will
510 be used primarily for clock synchronisation if possible).
511 The
512 preferred peer also determines the validity of the PPS signal - if
513 the preferred peer is suitable for synchronisation so is the PPS
514 signal.
515 .It Xo Ic addserver Ar peer_address
516 .Op Ar keyid
517 .Op Ar version
518 .Op Cm prefer
519 .Xc
520 Identical to the addpeer command, except that the operating
521 mode is client.
522 .It Xo Ic broadcast Ar peer_address
523 .Op Ar keyid
524 .Op Ar version
525 .Op Cm prefer
526 .Xc
527 Identical to the addpeer command, except that the operating
528 mode is broadcast.
529 In this case a valid key identifier and key are
530 required.
531 The
532 .Ar peer_address
533 parameter can be the broadcast
534 address of the local network or a multicast group address assigned
535 to NTP.
536 If a multicast address, a multicast-capable kernel is
537 required.
538 .It Ic unconfig Ar peer_address ...
539 This command causes the configured bit to be removed from the
540 specified peer(s).
541 In many cases this will cause the peer
542 association to be deleted.
543 When appropriate, however, the
544 association may persist in an unconfigured mode if the remote peer
545 is willing to continue on in this fashion.
546 .It Xo Ic fudge Ar peer_address
547 .Op Cm time1
548 .Op Cm time2
549 .Op Ar stratum
550 .Op Ar refid
551 .Xc
552 This command provides a way to set certain data for a reference
553 clock.
554 See the source listing for further information.
555 .It Ic enable Ar flag ...
556 .It Ic disable Ar flag ...
557 These commands operate in the same way as the
558 .Ic enable
559 and
560 .Ic disable
561 configuration file commands of
562 .Xr ntpd 8  .
563 Following is a description of the flags.
564 Note that only the
565 .Cm auth  ,
566 .Cm bclient ,
567 .Cm monitor ,
568 .Cm pll ,
569 .Cm pps
570 and
571 .Cm stats
572 flags can be set by
573 .Nm ;
574 the
575 .Cm pll_kernel
576 and
577 .Cm pps_kernel
578 flags are
579 read-only.
580 .Bl -tag -width indent
581 .It Cm auth
582 Enables the server to synchronize with unconfigured peers only
583 if the peer has been correctly authenticated using a trusted key
584 and key identifier.
585 The default for this flag is enable.
586 .It Cm bclient
587 Enables the server to listen for a message from a broadcast or
588 multicast server, as in the
589 .Ic multicastclient
590 command with
591 default address.
592 The default for this flag is disable.
593 .It Cm monitor
594 Enables the monitoring facility.
595 See the
596 .Ic monlist
597 command for further information.
598 The
599 default for this flag is enable.
600 .It Cm pll
601 Enables the server to adjust its local clock by means of NTP.
602 If disabled, the local clock free-runs at its intrinsic time and
603 frequency offset.
604 This flag is useful in case the local clock is
605 controlled by some other device or protocol and NTP is used only to
606 provide synchronization to other clients.
607 In this case, the local
608 clock driver is used.
609 See the
610 .Qq "Reference Clock Drivers"
611 page
612 (available as part of the HTML documentation
613 provided in
614 .Pa /usr/share/doc/ntp )
615 page for further information.
616 The default for
617 this flag is enable.
618 .It Cm pps
619 Enables the pulse-per-second (PPS) signal when frequency and
620 time is disciplined by the precision time kernel modifications.
621 See
622 the
623 .Qq "A Kernel Model for Precision Timekeeping"
624 page for further information.
625 The default for this flag is
626 disable.
627 .It Cm stats
628 Enables the statistics facility.
629 See the
630 .Sx Monitoring Options
631 section
632 of the
633 .Xr ntp.conf 5
634 page for further information.
635 The default for this flag is enable.
636 .It Cm pll_kernel
637 When the precision time kernel modifications are installed,
638 this indicates the kernel controls the clock discipline; otherwise,
639 the daemon controls the clock discipline.
640 .It Cm pps_kernel
641 When the precision time kernel modifications are installed and
642 a pulse-per-second (PPS) signal is available, this indicates the
643 PPS signal controls the clock discipline; otherwise, the daemon or
644 kernel controls the clock discipline, as indicated by the
645 .Cm pll_kernel
646 flag.
647 .El
648 .It Xo Ic restrict Ar address Ar mask
649 .Ar flag ...
650 .Xc
651 This command operates in the same way as the
652 .Ic restrict
653 configuration file commands of
654 .Xr ntpd 8  .
655 .It Xo Ic unrestrict Ar address Ar mask
656 .Ar flag ...
657 .Xc
658 Unrestrict the matching entry from the restrict list.
659 .It Xo Ic delrestrict Ar address Ar mask
660 .Op Cm ntpport
661 .Xc
662 Delete the matching entry from the restrict list.
663 .It Ic readkeys
664 Causes the current set of authentication keys to be purged and
665 a new set to be obtained by rereading the keys file (which must
666 have been specified in the
667 .Xr ntpd 8
668 configuration file).
669 This
670 allows encryption keys to be changed without restarting the
671 server.
672 .It Ic trustedkey Ar keyid ...
673 .It Ic untrustedkey Ar keyid ...
674 These commands operate in the same way as the
675 .Ic trustedkey
676 and
677 .Ic untrustedkey
678 configuration file
679 commands of
680 .Xr ntpd 8  .
681 .It Ic authinfo
682 Returns information concerning the authentication module,
683 including known keys and counts of encryptions and decryptions
684 which have been done.
685 .It Ic traps
686 Display the traps set in the server.
687 See the source listing for
688 further information.
689 .It Xo Ic addtrap Ar address
690 .Op Ar port
691 .Op Ar interface
692 .Xc
693 Set a trap for asynchronous messages.
694 See the source listing
695 for further information.
696 .It Xo Ic clrtrap Ar address
697 .Op Ar port
698 .Op Ar interface
699 .Xc
700 Clear a trap for asynchronous messages.
701 See the source listing
702 for further information.
703 .It Ic reset
704 Clear the statistics counters in various modules of the server.
705 See the source listing for further information.
706 .El
707 .Sh SEE ALSO
708 .Xr ntp.conf 5 ,
709 .Xr ntpd 8
710 .Rs
711 .%A David L. Mills
712 .%T Network Time Protocol (Version 3)
713 .%O RFC1305
714 .Re
715 .Sh BUGS
716 The
717 .Nm
718 utility is a crude hack.
719 Much of the information it shows is
720 deadly boring and could only be loved by its implementer.
721 The
722 program was designed so that new (and temporary) features were easy
723 to hack in, at great expense to the program's ease of use.
724 Despite
725 this, the program is occasionally useful.