Etc - Time Server (ntpd)


2002-11-15

NTPD is a daemon capable of retrieving time from a time server. It can also function as a time server itself. NTPD can retrive the time from an NTP server, and then broadcast the time and update all the other computers on a LAN.

NTPD has a few advantages over other time synchronization clients. NTPD not only retrieves the time from a time server, but also runs as a daemon in the background. As it periodically gets the updated time from an NTP server NTPD will record how much drift has occured in /etc/ntp/drift. Over time it will know exactly how much its clock drifts and NTPD will update the time periodically to keep nearly perfect time even without the NTP server.

Installation on NTPD is quite simple. If its not already installed do this:

# cd /usr/ports/net/ntp
# make install

Configuration of NTPD is a little more difficult. It depends entirely on what you want to do. I put a few sample /etc/ntp.conf files below. For more information about configuration options run “man ntp.conf”

You may have to create /etc/ntp.conf, and /etc/ntp if they don’t already exist.

Client that just updates time for itself

# vi /etc/ntp.conf
server anytimeserver.com
authenticate no
driftfile /etc/ntp/drift

Client/Server for broadcasting time accross a network

# vi /etc/ntp.conf
server anytimeserver.com

broadcast 10.0.217.255 # for a local 8 bit subnet
broadcast 10.0.218.255
broadcast 10.0.219.255
broadcast 10.0.220.255
broadcastdelay  0.008
authenticate no
driftfile /etc/ntp/drift

Broadcasting Client

# vi /etc/ntp.conf
broadcastclient yes
authenticate no
driftfile /etc/ntp/drift

One thing I learned is not to expect instant results. NTPD takes several minutes of warming up before it starts allowing time updates. I would wait 20 minutes after starting the daemon before concluding that its not working. Also right after running check the /var/log/messages for any errors.

For a list of public NTP servers visit:
http://www.eecis.udel.edu/~mills/ntp/clock1.html