Previous Section  < Day Day Up >  Next Section

Recipe 19.3. Connecting to a Local Time Server

19.3.1 Problem

You were tired of seeing a different incorrect time on every machine in your shop. So you set up a local time server—now how do you connect the clients?

19.3.2 Solution

Install or update ntp on the client PCs, and make sure the ntp daemon is not running:

# /etc/init.d/ntpd stop

On Debian, use:

# /etc/init.d/ntp-server stop

Edit /etc/ntp.conf to point to the local time server:

# /etc/ntp.conf

driftfile  /etc/ntp.drift

logfile  /var/log/ntp.logdriftfile

   

#use either hostnames or IPs

server 192.168.1.101

You can also include a fallback, in case the time server becomes unavailable:

# local fudge if network servers not available

# stratum 10 means low priority

server  127.127.1.0

fudge   127.127.1.0 stratum 10

ntp will continue to keep the time, based on past performance, until the server becomes available.

Now run ntpdate, pointing to the local server:

# ntpdate 192.168.1.101

Start up ntpd:

# /etc/init.d/ntpd start

On Debian, use:

# /etc/init.d/ntp-server start

Again, it may take a few minutes for a query to show any results:

# ntpq -p

 remote refid st t when poll reach delay offset jitter

 =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  = 

 =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =

 *clock.sjc.he.ne .CDMA. 1 u 21 64 377 98.269 15.298 4.000

19.3.3 Discussion

It is a good practice to also add some access controls; see the next recipe for /etc/ntp.conf access rules and some sample iptables rules.

Windows clients should use the free Automachron sntp (Simple Network Time Protocol) client. It works on all versions of Windows, is easy to configure, and is free of cost (although if you use it, it would be a nice gesture to click the PayPal link on the author's web site and send him a few dollars). Download it from http://www.oneguycoding.com/automachron.

Automachron has a nice feature for dialup connections—the "Wait for dialup connection" setting. It won't attempt to synchronize until a connection is established. It is also easy to set the synchronization intervals.

19.3.4 See Also

    Previous Section  < Day Day Up >  Next Section