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