Time synchronization – xntpd
This article shows you how to ensure the clock on your computer is kept synchronized. It originally dealt only with xntpd, but this is also applicable to ntpd.
Details for 5.x were added on 15 July 2004.
2 August 1998
Late last night I was reading up on Apache, the http server. It seems a good idea to install a time synchronization daemon because parts of http are expressed as the time of day. So I started looking up some information. xntpd is a Network Time Protocol daemon. I decided to go with that. It comes with FreeBSD; very little effort is required to get it running.
NOTE: under later versions of FreeBSD, notably 4.*, the xntpd binary has been replaced with ntpd. However, the following options will work as shown.
1. Create /etc/ntp.conf: server <address of time server> driftfile /etc/ntp.drift Note: Under 5.*, you do not have to include the driftfile line. 2. Enable xntpd by adding the following entries to /etc/rc.conf. See /etc/defaults/rc.conf for the values you need. They should look something like this:Under 3.* xntpd_enable="YES" xntpd_flags="-c /etc/ntp.conf -p /var/run/xntpd.pid"Under 4.*, you should use this xntpd_enable="YES" xntpd_flags="-c /etc/ntp.conf -p /var/run/ntpd.pid"Under 5.*, you should use this ntpd_enable="YES"3. On the next reboot you'll be syncing clocks automatically.4. Or you can issue this command:Under 3.*/usr/sbin/xntpd -c /etc/ntp.conf -p /var/run/xntpd.pidbut under 4.*, /usr/sbin/ntpd -c /etc/ntp.conf -p /var/run/ntpd.pidand under 5.*, /usr/sbin/ntpd -p /var/run/ntpd.pid -f /var/db/ntpd.driftFor more information on xntpd, try man xntpd or the online manual.
I use my ISP as a time server. You might want to ask your ISP if they provide such a service. If they do, use them. If they don’t, try the one resources listed at the end of this article. It’s also been pointed out to me that it might pay to use more than one timer server.
/etc/ntp.confHere is the contents of my xntpd configuration file. You can use it as an example, but you should not use the servers listed below. They will not be appropriate for you as they are too far away. I suggest you use your ISP as a time server. That’s what I’m doing.
server actrix.gen.nz driftfile /etc/ntp.drift
Use your FreeBSD box as a time server for your subnetIf you are running several machines at home, one of them should act as a server for the others. There is no reason for each of the machines to individually access a time server. In fact, it’s an ineffecient use of resources which increases traffic.
Once you go through the above installation process, your FreeBSD box can act as both a client and a server. Thus, it can act as a server for the rest of your subnet. I run several NT boxes on my subnet. I installed a time client on those machines and they now synchronize with the FreeBSD box. In this solution, the gateway machine talks to the external time servers and my local subnet coordinates their time with the gateway.
A side-benefit of this approach is that should anything go wrong with the time on your network, you only need to change your gateway time and all other machines will pick up the change.
xntpd as both client and serverNote that xntpd can act as both a server and as a client at the same time. One box is designated as your local server and all of your other boxes should point to it. The server will point to your ISP. Here are some sample configuration files to do this:
/etc/ntp.conf on the server
server your.isp.com driftfile /etc/ntp.drift
/etc/ntp.conf on the clients
server your.local.server driftfile /etc/ntp.drift
You should change your.isp.com to the host name of your ISPs time server. Contact your ISP for details. You should also change your.local.server to the IP address or the host name of the box on your subnet which will service your other boxes.
– I use this but it may be too much for you. It has lots of features, such as finger,
traceroute, whois, etc., which are not time related. Recently, I’ve found
it difficult to find a download location. Here’s a few I’ve found to work (as of 6 August 2001)
for version 1.4 (the latest). A quick search for “Alexander Danileiko” or NetLab should help. (freeware)
- Tardis seems to be pretty popular, but I’ve never tried it. (shareware)
- YATS is something I’ve only recently heard of, but never tried. (shareware)
- Dimension 4 – time synchronization utility for Windows 95 and Windows NT 4.0. (freeware)
- MR Tech ClockAlign 1.1 – recommended by Allan Carhart who says although this software is beta, he’s never "never seen any instability that you might expect with a Beta". (freeware)
- AboutTime – recommended by Enriko Groen. (freeware)
- Automachron – from One Guy Coding and recommended by Ben Mottram as being a “sound win32 client”.
- NetTime – a simple time synchronization client for Windows 95/98/NT/2000. Its main claim to fame is that it is small, simple and unobtrusive. And, of course, it’s free software.
Whatever client you choose, it must be able to use SNTP (Simple Network Time Protocol), which is what xntpd uses.
Note that if you are running Samba, it can be a time server. See the end of this article for details.
1 September 1998Today I installed the time daemon on the new system. It ran first time.
Time related resources
|UTC, TAI, and UNIX time an explanation of each and how they differ||Public NTP Time Servers good stuff and some sound guidelines||Time WWW server copies of the software you might want. Lots of links to other information.||US Navy time servers a good resource||RFC 1769 Simple Network Time Protocol (SNTP)|