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