Setting up an OpenBSD NTP server (and time synchronizing Windows clients)

(Last modified: 04/09/01)

Introduction

Setting up your local network for time synchronization can seem overwhelming, especially when you have little to start with. I figured I would write a document on setting up the Network Time Protocol, once I had a basic working knowledge and a setup to go along.

If you have any questions or comments, feel free to drop me a note.

Note that I've written most of this document from memory. It appears to be correct; if I've missed something, let me know.

Described Network

Here's my network set up:


                                (( Internet ))
                                       |
                               ------------------
                              | OpenBSD firewall |
                               ------------------
                                       |
                       ( various windows and unix hosts )
I will describe the setup on the OpenBSD firewall, and my main desktop machine (which is a Windows based box).

Initial Setup

To start, make sure you are running a recent version of OpenBSD. The latest available at the time of this writing is 2.8-current. I suggest making sure you have the latest rc.conf, rc.local and rc.securelevel files in place.

Also, make sure your /etc/localtime file is linked to the correct time zone file for your region. For example, if you were in the Canadian Atlantic time zone, your /etc/localtime file should be linked as follows (from afterboot(8)):

           ln -fs /usr/share/zoneinfo/Canada/Atlantic /etc/localtime
This will designate Atlantic Standard Time as your system's time zone.

Compiling NTPD

Next, compile and install NTPD, located in the OpenBSD ports collection directory, net/ntpd. This can (usually) be accomplished by typing "make all install" as root in that directory.

Configuring NTPD

Next, create an NTP configuration file. This is located at /etc/ntp.conf, by default. Placing the following in the configuration file will more than likely suit your needs:

server 165.227.1.1 prefer
server 140.162.1.3

restrict default ignore
restrict 165.227.1.1 noquery nomodify notrap nopeer
restrict 140.162.1.3 noquery nomodify notrap nopeer
restrict 127.0.0.1 nomodify
See the references section for information on where to find public NTP servers.

Initializing the System Clock

Next, run ntpdate -b <server> to synchronize your system's time, where <server> is one of the servers in your ntpd.conf file.

If you would like the OpenBSD machine's system time to be synchronized on boot, modify the ntpdate_flags variable in /etc/rc.conf to equal one of the servers specified in your ntp.conf file.

Running this command is a good idea, as any significant deviation of your system's time from the actual time (as reported by the configured servers) will cause NTPD to exit (and therefore leave your system time desynched from the rest of the world).

Running NTPD

Finally, run NTPD. By default, it is installed in /usr/local/sbin/ntpd.

To monitor the status of the NTP daemon, use the utility /usr/local/sbin/ntpq. This is an interactive client to the NTP daemon running on your machine. The two commands I find most helpful in debugging the NTP daemon are "pe" and "rv", which allow you to see a peer list and read the current NTP variables, respectively. See the NTPD documentation for more details.

If you would like NTPD to run automatically the next time your system is re- started, modify the ntpd variable in /etc/rc.conf to equal "YES".

Providing NTP Access to Other Hosts

If you use the configuration above, all requests from hosts other than those specified will be ignored. To enable all hosts on the network 10.0.0.0/24 to query your server for NTP information, add the following line to ntp.conf:

restrict 10.0.0.0 mask 255.255.255.0 nomodify nopeer
Use your network address and mask if applicable.

NTP Clients for Platforms Other Than UNIX

There are a number of clients available for platforms other than UNIX. For Windows based machines, I suggest AboutTime: a small, easy to use, and free NTP client. It can be downloaded at http://www.arachnoid.com/abouttime/.

Configuring AboutTime

The AboutTime version described here is 4.8.

To configure AboutTime to poll your local NTP server (i.e. the OpenBSD box), start the application and remove all hosts under the Time Hosts tab.

Next, add an entry for your local (OpenBSD) NTP server. Set the protocol to SNTP.

Next (optional), disable all protocols under Time Servers, except SNTP.

Under Options, make sure it is polling at a reasonable interval.

Finally, have AboutTime set the time at startup.

I also suggest making a shortcut to the AboutTime executable in the Startup folder for the system. Under Windows NT, this directory is (usually) located at:

C:\WINNT\Profiles\All Users\Start Menu\Programs\Startup
When the machine boots, AboutTime will now be started automatically. If the Set Time When Starting option was set, it will also sync with your local time server.

Test your setup: under the Control/Time Client tab, click Set Time, and make sure the Windows machine synchronizes properly. If not, recheck your configuration on both the OpenBSD and Windows machines.

Additional Notes

If the Windows machine is behind an hour when synching, make sure it accounts for Daylight Savings Time. In the Control Panel, double click Date and Time, then click the Time Zone tab. Make sure "Automatically adjust clock for daylight savings changes" is checked.

To get a fairly accurate reading of the current time from the US Naval Observatory, check out: http://tycho.usno.navy.mil/cgi-bin/timer.pl.

References

Information regarding NTP configuration can be found at:

http://www.eecis.udel.edu/~mills/ntp/html/notes.htm

A List of public NTP servers can be found at:

http://www.eecis.udel.edu/~mills/ntp/servers.html

Complete documentation can be found at:

http://www.eecis.udel.edu/~mills/ntp/html/index.htm

The Time Synchronization homepage:

http://www.eecis.udel.edu/~ntp/

Credits

Written by Robert Mooney (rjmooney\@impetus\.us).

Copyright (c) 2000,2001 Robert Mooney, All rights reserved.

This document may be freely distributed and modified, so long as the original author is credited.

If you are inclined, you can leave me a tip with PayPal. Sign up for it.


 Return to the Main index