< Day Day Up > |
Recipe 19.2. Building a Local Time Server19.2.1 ProblemYou want to set up a local time server. It will synchronize with a public time server, and your LAN clients will connect to the local machine. The PC acting as the local time server has a full-time Internet connection. 19.2.2 SolutionFirst, install or upgrade ntp on the PC that is going to act as a time server for your LAN. You'll also want ntpdate. Next, make sure the ntp daemon is not running: # /etc/init.d/ntpd stop On Debian, use: # /etc/init.d/ntp-server stop Make these entries in /etc/ntp.conf, and create the driftfile and logfile if they do not already exist. root should own them (chmod 644). #/etc/ntp.conf driftfile /etc/ntp.drift logfile /var/log/ntp.log server pool.ntp.org server pool.ntp.org server pool.ntp.org Make the initial time correction with ntpdate: # ntpdate pool.ntp.org Then start up ntpd: # /etc/init.d/ntpd start On Debian, use: # /etc/init.d/ntp-server start Use ntpq to see which servers you're connected to: # ntpq -p
remote refid st t when poll reach delay offset jitter
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
= = = = = = = = = = = = = = = = = = = = = = = = = =
+clock.fmt.he.ne .GPS. 1 u 37 64 377 105.562 26.771 2.539
+dewey.lib.ci.ph reaper.twc.weat 2 u 25 64 377 398.666 -30.285 51.555
*clock.sjc.he.ne .CDMA. 1 u 21 64 377 98.269 15.298 4.000 Be patient, because it takes a few minutes for a server list to appear and up to 30 minutes for the first correction to take place. The * and + prefixes indicate that the connections were successful and synchronization is occurring.
19.2.3 DiscussionBe sure to get the ntp rpm, not xntp. ntp is newer and replaces xntp. Debian users need ntp-simple, ntp-doc, and ntp-server. ntpd makes small, incremental changes over a period of time. By itself, it will take hours, or even days, to adjust the system time, depending how far off it is. If the system time is off by more than 60 minutes, ntpdate is the quickest way to make the initial correction. ntpdate will not run if ntpd is running. The maintainers at ntp.org are trying to deprecate ntpdate, claiming that ntpd -g, which is ntpd's "burst" command, does the same thing. Unfortunately, it doesn't handle corrections larger than 60 minutes any faster than ntpd, so ntpdate is still useful. Using the same entry in ntp.conf three times—server pool.ntp.org—puts three different hits on the DNS pool at your disposal, so you'll never have to worry about servers being unavailable. pool.ntp.org is a worldwide DNS round-robin of participating time servers. See Recipe Recipe 19.5 for more pool options, and how to get the best performance. 19.2.4 See Also
|
< Day Day Up > |