]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - 6/usr.sbin/ntp/doc/ntpd.8
Clone Kip's Xen on stable/6 tree so that I can work on improving FreeBSD/amd64
[FreeBSD/FreeBSD.git] / 6 / usr.sbin / ntp / doc / ntpd.8
1 .\"
2 .\" $FreeBSD$
3 .\"
4 .Dd May 17, 2006
5 .Dt NTPD 8
6 .Os
7 .Sh NAME
8 .Nm ntpd
9 .Nd Network Time Protocol (NTP) daemon
10 .Sh SYNOPSIS
11 .Nm
12 .Op Fl aAbDdgLmnPqx
13 .Op Fl c Ar conffile
14 .Op Fl f Ar driftfile
15 .Op Fl k Ar keyfile
16 .Op Fl l Ar logfile
17 .Op Fl p Ar pidfile
18 .Op Fl r Ar broadcastdelay
19 .Op Fl s Ar statsdir
20 .Op Fl t Ar key
21 .Op Fl v Ar variable
22 .Op Fl V Ar variable
23 .Sh DESCRIPTION
24 The
25 .Nm
26 utility is an operating system daemon which sets
27 and maintains the system time of day in synchronism with Internet
28 standard time servers.
29 It is a complete implementation of the
30 Network Time Protocol (NTP) version 4, but also retains
31 compatibility with version 3, as defined by RFC-1305, and version 1
32 and 2, as defined by RFC-1059 and RFC-1119, respectively.
33 .Pp
34 The
35 .Nm
36 utility does most computations in 64-bit floating point
37 arithmetic and does relatively clumsy 64-bit fixed point operations
38 only when necessary to preserve the ultimate precision, about 232
39 picoseconds.
40 While the ultimate precision, is not achievable with
41 ordinary workstations and networks of today, it may be required
42 with future gigahertz CPU clocks and gigabit LANs.
43 .Pp
44 Ordinarily,
45 .Nm
46 reads the
47 .Xr ntp.conf 5
48 configuration file at startup time in order to determine the
49 synchronization sources and operating modes.
50 It is also possible to
51 specify a working, although limited, configuration entirely on the
52 command line, obviating the need for a configuration file.
53 This may
54 be particularly useful when the local host is to be configured as a
55 broadcast/multicast client, with all peers being determined by
56 listening to broadcasts at run time.
57 .Pp
58 If NetInfo support is built into
59 .Nm ,
60 then
61 .Nm
62 will attempt to read its configuration from the
63 NetInfo if the default
64 .Xr ntp.conf 5
65 file cannot be read and no file is
66 specified by the
67 .Fl c
68 option.
69 .Pp
70 Various internal
71 .Nm
72 variables can be displayed and
73 configuration options altered while the
74 .Nm
75 is running
76 using the
77 .Xr ntpq 8
78 and
79 .Xr ntpdc 8
80 utility programs.
81 .Pp
82 When
83 .Nm
84 starts it looks at the value of
85 .Cm umask 2 ,
86 and if zero
87 .Nm
88 will set the
89 .Cm umask 2
90 to 022.
91 .Pp
92 The following options are available:
93 .Bl -tag -width indent
94 .It Fl a
95 Require cryptographic authentication for broadcast client,
96 multicast client and symmetric passive associations.
97 This is the default.
98 .It Fl A
99 Do not require cryptographic authentication for broadcast client,
100 multicast client and symmetric passive associations.
101 This is almost never a good idea.
102 .It Fl b
103 Enable the client to synchronize to broadcast servers.
104 .It Fl c Ar conffile
105 Specify the name and path of the configuration file, default
106 .Pa /etc/ntp.conf .
107 .It Fl d
108 Specify debugging mode. This option may occur more than once,
109 with each occurrence indicating greater detail of display.
110 .It Fl D Ar level
111 Specify debugging level directly.
112 .It Fl f Ar driftfile
113 Specify the name and path of the frequency file, default
114 .Pa /etc/ntp.drift .
115 This is the same operation as the
116 .Ic driftfile Ar driftfile
117 configuration command.
118 .It Fl g
119 Normally,
120 .Nm
121 exits with a message to the system log if the offset exceeds
122 the panic threshold, which is 1000 s by default.
123 This option allows thetime to be set to any value without restriction;
124 however, this can happen only once.
125 If the threshold is exceeded after that,
126 .Nm
127 will exit with a message to the system log.
128 This option can be used with the
129 .Fl q
130 and
131 .Fl x
132 options. See the
133 .Ic tinker
134 command for other options.
135 .It Fl k Ar keyfile
136 Specify the name and path of the symmetric key file, default
137 .Pa /etc/ntp.keys .
138 This is the same operation as the
139 .Ic keys Ar keyfile
140 configuration command.
141 .It Fl l Ar logfile
142 Specify the name and path of the log file.
143 The default is the system log file.
144 This is the same operation as the
145 .Ic logfile Ar logfile
146 configuration command.
147 .It Fl L
148 Do not listen to virtual IPs. The default is to listen.
149 .It Fl m
150 Enable the client to synchronize to multicast servers at the IPv4 multicast
151 group address 224.0.1.1.
152 .It Fl n
153 Do not fork.
154 .It Fl N
155 To the extent permitted by the operating system, run the
156 .Nm
157 at the highest priority.
158 .It Fl p Ar pidfile
159 Specify the name and path of the file used to record the
160 .Nm
161 process ID.
162 This is the same operation as the
163 .Ic pidfile Ar pidfile
164 configuration command.
165 .It Fl P Ar priority
166 To the extent permitted by the operating system, run the
167 .Nm
168 at the specified priority.
169 .It Fl q
170 Exit the
171 .Nm
172 just after the first time the clock is
173 set.
174 This behavior mimics that of the
175 .Xr ntpdate 8
176 program,
177 which is to be retired.
178 The
179 .Fl g
180 and
181 .Fl x
182 options can
183 be used with this option.
184 Note: The kernel time discipline is disabled with this option.
185 .It Fl r Ar broadcastdelay
186 Specify the default propagation delay from the
187 broadcast/multicast server to this client.
188 This is necessary
189 only if the delay cannot be computed automatically by the
190 protocol.
191 .It Fl s Ar statsdir
192 Specify the directory path for files created by the statistics
193 facility.
194 This is the same operation as the
195 .Ic statsdir Ar statsdir
196 configuration command.
197 .It Fl t Ar key
198 Add a key number to the trusted key list.
199 This option can occur more than once.
200 .It Fl v Ar variable
201 .It Fl V Ar variable
202 Add a system variable listed by default.
203 .It Fl x
204 Normally, the time is slewed if the offset is less than the
205 step threshold, which is 128 ms by default, and stepped if above
206 the threshold.
207 This option sets the threshold to 600 s,
208 which is well within the accuracy window to set the clock manually.
209 Note: Since the slew rate of typical Unix kernels is limited to 0.5 ms/s,
210 each second of adjustment requires an amortization interval of 2000 s.
211 Thus, an adjustment as much as 600 s will take almost 14 days to complete.
212 This option can be used with the
213 .Fl g
214 and
215 .Fl q
216 options.
217 See the
218 .Ic tinker
219 command for other options.
220 Note: The kernel time discipline is disabled with this option.
221 .El
222 .Ss "How NTP Operates"
223 The
224 .Nm
225 utility operates by exchanging messages with
226 one or more configured servers at designated poll intervals.
227 When
228 started, whether for the first or subsequent times, the program
229 requires several exchanges from the majority of these servers so
230 the signal processing and mitigation algorithms can accumulate and
231 groom the data and set the clock.
232 In order to protect the network
233 from bursts, the initial poll interval for each server is delayed
234 an interval randomized over a few seconds.
235 At the default initial poll
236 interval of 64s, several minutes can elapse before the clock is
237 set.
238 The initial delay to set the clock can be reduced using the
239 .Cm iburst
240 keyword with the
241 .Ic server
242 configuration
243 command, as described in
244 .Xr ntp.conf 5 .
245 .Pp
246 Most operating systems and hardware of today incorporate a
247 time-of-year (TOY) chip to maintain the time during periods when
248 the power is off.
249 When the machine is booted, the chip is used to
250 initialize the operating system time.
251 After the machine has
252 synchronized to a NTP server, the operating system corrects the
253 chip from time to time.
254 In case there is no TOY chip or for some
255 reason its time is more than 1000s from the server time,
256 .Nm
257 assumes something must be terribly wrong and the only
258 reliable action is for the operator to intervene and set the clock
259 by hand.
260 This causes
261 .Nm
262 to exit with a panic message to
263 the system log.
264 The
265 .Fl g
266 option overrides this check and the
267 clock will be set to the server time regardless of the chip time.
268 However, and to protect against broken hardware, such as when the
269 CMOS battery fails or the clock counter becomes defective, once the
270 clock has been set, an error greater than 1000s will cause
271 .Nm
272 to exit anyway.
273 .Pp
274 Under ordinary conditions,
275 .Nm
276 adjusts the clock in
277 small steps so that the timescale is effectively continuous and
278 without discontinuities.
279 Under conditions of extreme network
280 congestion, the roundtrip delay jitter can exceed three seconds and
281 the synchronization distance, which is equal to one-half the
282 roundtrip delay plus error budget terms, can become very large.
283 The
284 .Nm
285 algorithms discard sample offsets exceeding 128 ms,
286 unless the interval during which no sample offset is less than 128
287 ms exceeds 900s.
288 The first sample after that, no matter what the
289 offset, steps the clock to the indicated time.
290 In practice this
291 reduces the false alarm rate where the clock is stepped in error to
292 a vanishingly low incidence.
293 .Pp
294 As the result of this behavior, once the clock has been set, it
295 very rarely strays more than 128 ms, even under extreme cases of
296 network path congestion and jitter.
297 Sometimes, in particular when
298 .Nm
299 is first started, the error might exceed 128 ms.
300 This
301 may on occasion cause the clock to be set backwards if the local
302 clock time is more than 128 s in the future relative to the server.
303 In some applications, this behavior may be unacceptable.
304 If the
305 .Fl x
306 option is included on the command line, the clock will
307 never be stepped and only slew corrections will be used.
308 .Pp
309 The issues should be carefully explored before deciding to use
310 the
311 .Fl x
312 option.
313 The maximum slew rate possible is limited
314 to 500 parts-per-million (PPM) as a consequence of the correctness
315 principles on which the NTP protocol and algorithm design are
316 based.
317 As a result, the local clock can take a long time to
318 converge to an acceptable offset, about 2,000 s for each second the
319 clock is outside the acceptable range.
320 During this interval the
321 local clock will not be consistent with any other network clock and
322 the system cannot be used for distributed applications that require
323 correctly synchronized network time.
324 .Pp
325 In spite of the above precautions, sometimes when large
326 frequency errors are present the resulting time offsets stray
327 outside the 128-ms range and an eventual step or slew time
328 correction is required.
329 If following such a correction the
330 frequency error is so large that the first sample is outside the
331 acceptable range,
332 .Nm
333 enters the same state as when the
334 .Pa ntp.drift
335 file is not present.
336 The intent of this behavior
337 is to quickly correct the frequency and restore operation to the
338 normal tracking mode.
339 In the most extreme cases
340 (
341 .Cm time.ien.it
342 comes to mind), there may be occasional
343 step/slew corrections and subsequent frequency corrections.
344 It
345 helps in these cases to use the
346 .Cm burst
347 keyword when
348 configuring the server.
349 .Ss "Frequency Discipline"
350 The
351 .Nm
352 behavior at startup depends on whether the
353 frequency file, usually
354 .Pa ntp.drift ,
355 exists.
356 This file
357 contains the latest estimate of clock frequency error.
358 When the
359 .Nm
360 is started and the file does not exist, the
361 .Nm
362 enters a special mode designed to quickly adapt to
363 the particular system clock oscillator time and frequency error.
364 This takes approximately 15 minutes, after which the time and
365 frequency are set to nominal values and the
366 .Nm
367 enters
368 normal mode, where the time and frequency are continuously tracked
369 relative to the server.
370 After one hour the frequency file is
371 created and the current frequency offset written to it.
372 When the
373 .Nm
374 is started and the file does exist, the
375 .Nm
376 frequency is initialized from the file and enters normal mode
377 immediately.
378 After that the current frequency offset is written to
379 the file at hourly intervals.
380 .Ss "Operating Modes"
381 The
382 .Nm
383 utility can operate in any of several modes, including
384 symmetric active/passive, client/server broadcast/multicast and
385 manycast, as described in the
386 .Qq Association Management
387 page
388 (available as part of the HTML documentation
389 provided in
390 .Pa /usr/share/doc/ntp ) .
391 It normally operates continuously while
392 monitoring for small changes in frequency and trimming the clock
393 for the ultimate precision.
394 However, it can operate in a one-time
395 mode where the time is set from an external server and frequency is
396 set from a previously recorded frequency file.
397 A
398 broadcast/multicast or manycast client can discover remote servers,
399 compute server-client propagation delay correction factors and
400 configure itself automatically.
401 This makes it possible to deploy a
402 fleet of workstations without specifying configuration details
403 specific to the local environment.
404 .Pp
405 By default,
406 .Nm
407 runs in continuous mode where each of
408 possibly several external servers is polled at intervals determined
409 by an intricate state machine.
410 The state machine measures the
411 incidental roundtrip delay jitter and oscillator frequency wander
412 and determines the best poll interval using a heuristic algorithm.
413 Ordinarily, and in most operating environments, the state machine
414 will start with 64s intervals and eventually increase in steps to
415 1024s.
416 A small amount of random variation is introduced in order to
417 avoid bunching at the servers.
418 In addition, should a server become
419 unreachable for some time, the poll interval is increased in steps
420 to 1024s in order to reduce network overhead.
421 .Pp
422 In some cases it may not be practical for
423 .Nm
424 to run
425 continuously.
426 A common workaround has been to run the
427 .Xr ntpdate 8
428 program from a
429 .Xr cron 8
430 job at designated
431 times.
432 However, this program does not have the crafted signal
433 processing, error checking and mitigation algorithms of
434 .Nm .
435 The
436 .Fl q
437 option is intended for this purpose.
438 Setting this option will cause
439 .Nm
440 to exit just after
441 setting the clock for the first time.
442 The procedure for initially
443 setting the clock is the same as in continuous mode; most
444 applications will probably want to specify the
445 .Cm iburst
446 keyword with the
447 .Ic server
448 configuration command.
449 With this
450 keyword a volley of messages are exchanged to groom the data and
451 the clock is set in about 10 s.
452 If nothing is heard after a
453 couple of minutes, the daemon times out and exits.
454 After a suitable
455 period of mourning, the
456 .Xr ntpdate 8
457 program may be
458 retired.
459 .Pp
460 When kernel support is available to discipline the clock
461 frequency, which is the case for stock Solaris, Tru64, Linux and
462 .Fx ,
463 a useful feature is available to discipline the clock
464 frequency.
465 First,
466 .Nm
467 is run in continuous mode with
468 selected servers in order to measure and record the intrinsic clock
469 frequency offset in the frequency file.
470 It may take some hours for
471 the frequency and offset to settle down.
472 Then the
473 .Nm
474 is
475 stopped and run in one-time mode as required.
476 At each startup, the
477 frequency is read from the file and initializes the kernel
478 frequency.
479 .Ss "Poll Interval Control"
480 This version of NTP includes an intricate state machine to
481 reduce the network load while maintaining a quality of
482 synchronization consistent with the observed jitter and wander.
483 There are a number of ways to tailor the operation in order enhance
484 accuracy by reducing the interval or to reduce network overhead by
485 increasing it.
486 However, the user is advised to carefully consider
487 the consequences of changing the poll adjustment range from the
488 default minimum of 64 s to the default maximum of 1,024 s.
489 The
490 default minimum can be changed with the
491 .Ic tinker
492 .Cm minpoll
493 command to a value not less than 16 s.
494 This value is used for all
495 configured associations, unless overridden by the
496 .Cm minpoll
497 option on the configuration command.
498 Note that most device drivers
499 will not operate properly if the poll interval is less than 64 s
500 and that the broadcast server and manycast client associations will
501 also use the default, unless overridden.
502 .Pp
503 In some cases involving dial up or toll services, it may be
504 useful to increase the minimum interval to a few tens of minutes
505 and maximum interval to a day or so.
506 Under normal operation
507 conditions, once the clock discipline loop has stabilized the
508 interval will be increased in steps from the minimum to the
509 maximum.
510 However, this assumes the intrinsic clock frequency error
511 is small enough for the discipline loop correct it.
512 The capture
513 range of the loop is 500 PPM at an interval of 64s decreasing by a
514 factor of two for each doubling of interval.
515 At a minimum of 1,024
516 s, for example, the capture range is only 31 PPM.
517 If the intrinsic
518 error is greater than this, the drift file
519 .Pa ntp.drift
520 will
521 have to be specially tailored to reduce the residual error below
522 this limit.
523 Once this is done, the drift file is automatically
524 updated once per hour and is available to initialize the frequency
525 on subsequent daemon restarts.
526 .Ss "The huff-n'-puff Filter"
527 In scenarios where a considerable amount of data are to be
528 downloaded or uploaded over telephone modems, timekeeping quality
529 can be seriously degraded.
530 This occurs because the differential
531 delays on the two directions of transmission can be quite large.
532 In
533 many cases the apparent time errors are so large as to exceed the
534 step threshold and a step correction can occur during and after the
535 data transfer is in progress.
536 .Pp
537 The huff-n'-puff filter is designed to correct the apparent time
538 offset in these cases.
539 It depends on knowledge of the propagation
540 delay when no other traffic is present.
541 In common scenarios this
542 occurs during other than work hours.
543 The filter maintains a shift
544 register that remembers the minimum delay over the most recent
545 interval measured usually in hours.
546 Under conditions of severe
547 delay, the filter corrects the apparent offset using the sign of
548 the offset and the difference between the apparent delay and
549 minimum delay.
550 The name of the filter reflects the negative (huff)
551 and positive (puff) correction, which depends on the sign of the
552 offset.
553 .Pp
554 The filter is activated by the
555 .Ic tinker
556 command and
557 .Cm huffpuff
558 keyword, as described in
559 .Xr ntp.conf 5 .
560 .Sh FILES
561 .Bl -tag -width /etc/ntp.drift -compact
562 .It Pa /etc/ntp.conf
563 the default name of the configuration file
564 .It Pa /etc/ntp.drift
565 the default name of the drift file
566 .It Pa /etc/ntp.keys
567 the default name of the key file
568 .El
569 .Sh SEE ALSO
570 .Xr ntp.conf 5 ,
571 .Xr ntpdate 8 ,
572 .Xr ntpdc 8 ,
573 .Xr ntpq 8
574 .Pp
575 In addition to the manual pages provided,
576 comprehensive documentation is available on the world wide web
577 at
578 .Li http://www.ntp.org/ .
579 A snapshot of this documentation is available in HTML format in
580 .Pa /usr/share/doc/ntp .
581 .Rs
582 .%A David L. Mills
583 .%T Network Time Protocol (Version 1)
584 .%O RFC1059
585 .Re
586 .Rs
587 .%A David L. Mills
588 .%T Network Time Protocol (Version 2)
589 .%O RFC1119
590 .Re
591 .Rs
592 .%A David L. Mills
593 .%T Network Time Protocol (Version 3)
594 .%O RFC1305
595 .Re
596 .Sh BUGS
597 The
598 .Nm
599 utility has gotten rather fat.
600 While not huge, it has gotten
601 larger than might be desirable for an elevated-priority
602 .Nm
603 running on a workstation, particularly since many of
604 the fancy features which consume the space were designed more with
605 a busy primary server, rather than a high stratum workstation in
606 mind.