The Network Time Protocol (NTP) is used to synchronize the time of a computer client or server to another server or reference time source, such as a radio or satellite receiver or modem. It provides accuracies typically within a millisecond on LANs and up to a few tens of milliseconds on WANs relative to Coordinated Universal Time (UTC) via a Global Positioning Service (GPS) receiver, for example. Typical NTP configurations utilize multiple redundant servers and diverse network paths in order to achieve high accuracy and reliability.

The NTP subnet in early 2003 includes well over a hundred public primary (stratum 1) servers synchronized directly to UTC by radio, satellite or modem and located in every continent of the globe, including Antarctica. Normally, client workstations and servers with a relatively small number of clients do not synchronize to primary servers. There are well over a hundred public secondary (stratum 2) servers synchronized to the primary servers and providing synchronization to a total well over 100,000 clients and servers in the Internet.

There are two programs that are used here: ntpd and ntpdate. The ntpd program operates by exchanging messages with one or more configured servers at designated poll intervals. When started, whether for the first or subsequent times, the program requires several exahanges from the majority of these servers so the signal processing and mitigation algorithms can accumulate and groom the data and set the clock. The ntpdate program can be run manually as necessary to set the host clock, or it can be run from the host startup script to set the clock at boot time. This is useful in some cases to set the clock initially before starting the NTP daemon ntpd. It is also possible to run ntpdate from a cron script. However, it is important to note that ntpdate with contrived cron scripts is no substitute for the NTP daemon, which uses sophisticated algorithms to maximize accuracy and reliability while minimizing resource use.

On OpenBSD, the NTP software is not installed by default, so we will have to do this first.

cd /usr/ports/net/ntp
make install

Now we have to edit the configuration file /etc/ntp.conf. This file contains the names of servers we want to synchronize to and the networks of clients we allow access to this server.

server prefer

restrict mask nomodify nopeer
restrict mask nomodify nopeer

OpenBSD starts ntpd automatically if it can find the daemon at /usr/local/sbin/ntpd. However, it does not call ntpdate at startup. So if you want that to happen, edit rc.conf.local.

Network Time Protocol (NTP)
Tagged on:     

Leave a Reply

Your email address will not be published. Required fields are marked *