NTP users are strongly urged to take immediate action to ensure that their NTP daemons are not susceptible to being used in distributed denial-of-service (DDoS) attacks. Please also take this opportunity to defeat denial-of-service attacks by implementing Ingress and Egress filtering through BCP38.

ntp-4.2.8p13 was released on 07 March 2019. It addresses 1 medium-severity security issue in ntpd, and provides 17 non-security bugfixes and 1 other improvements over 4.2.8p12.

3.1.1. What NTP is and what it does

The internal clocks of most computers are rather inaccurate. You can
correct the clock by hand on occasion, or you can use NTP to regulate
your clock to be much more accurate.

NTP stands for "Network Time Protocol". It is a way for computers to
exchange information about the exact time, so that they can regulate
their clocks.

NTP also stands for a particular daemon (continuously running program)
that uses the Network Time Protocol to determine the correct time and
regulate your computer's clock to show the correct time. The NTP
daemon software can be obtained from http://www.ntp.org. It runs on
Unix and Windows/NT systems. (There are other programs that use the
Network Time Protocol for setting your computer's clock as well -- see
3.1.10. Further resources for information.)

NTP can regulate your clock using a "reference clock", a device that
obtains accurate time information from an outside source and delivers
it to your computer. More commonly, NTP can regulate your clock by
obtaining time information from another NTP daemon. NTP can also
provide time information to other NTP daemons.

Once you install the NTP software and start it running, you must
provide it with a source of time information, either a reference
clock, or with the addresses of other NTP daemons. This document
describes the critical steps of installing the software and
configuring NTP to obtain time from other NTP daemons. Information about
using a reference clock with NTP is at http://www.eecis.udel.edu/~mills/ntp/html/refclock.html.

3.1.2. The names of the programs: Is it ntpd or xntpd?

Some operating systems supply the NTP programs (ntpd, ntpdate, ntpdc, ntpdq,
etc.) with filenames starting with "x" (xntpd, xntpdate, etc.).
Others use filenames without the "x".
This document uses the names without the "x".
Try to run the program using the name without the "x" first.
If you receive a "command not found" error, try the name with an "x".

The "x" versions of the programs are from version 3 of NTP. They are old, but some OS vendors still distribute these versions of NTP. The versions without the "x" are from version 4. The commands and options used in this document should work for either version.

These sites are kind enough to perform this service for you, you should follow any guidelines they request (asking permission first, donations, thank-you notes, whatever.)

Let's suppose you've picked clock.example.org, timekeeper.sample.com, ntp1.example.co.uk, and tick.anotherexample.net. Those aren't real sites, but I'll use them as examples in the rest of this document.

3.1.4. "Manually" set the clock correctly just once

HMS: This section is best for xntp (V3). ntpdate is deprecated in ntp4, see StartingNTP for more information.

Let's "manually" set the clock to the correct time just to start things off. When ntpd is running and finds your clock is wrong, it makes tiny little changes until the clock is right. This way applications don't get confused. However, on reboot, the clock may have lost a lot of time and since no applications are running yet, we can make a big timeleap to correct the clock without risk of confusing them. To do this, we use a different utility called ntpdate. It can't run at the same time as ntpd. We even give it the "-b" option so that it knows to leap forward or backwards in time to set the clock correctly.

This means that your clock was off by -111.106949 seconds, but now it's been brought up to date. The good news is that for an instant you were in sync. The bad news is that by the time you read this, your clock has drifted. Darn computers!

3.1.5. Set the clock correctly on every boot up

On reboot, you want to tell the system to sync up quickly. While your machine was down the CPU gets bored and plays with the clock. Haven't you ever been in a clock store waiting for your mother to make her purchase and started setting the clocks to funny times? It's like that, only your mother has nothing to do with this (I'm sure she's a very nice person, you just don't appreciate her enough).

Let's configure your system to run this command on boot up. Here's how to do this on various operating systems:

(people can volunteer the easiest way to do this on their favorite OS)

3.1.6. Keep the clock in sync permanently and continuously.

Having your clock set properly every time you boot is nice, if you reboot constantly. Of course, you could put that command in cron but we have a solution that is so much better you'll thank me in the morning. We'll run ntpd which will constantly keep your clock correct by making micro-adjustments all day long. Heck, ntpd is so smart that if you lose contact with all your NTP servers it will remember how bad your clock was and keep making adjustments based on past bad performance. Pretty cool, eh?

The NTP documentation has volumes about the various features and entire books can be written about the theory of operation of NTP. It's really quite amazing how the system works so precisely, so accurately, does the right thing through outages, detects and avoids misconfigured servers, conserves bandwidth, and as Jim Trocki once said, "fixes problems that you don't yet realize you have". However, you don't care about that, you just want a simple configuration that works. Here's one.

It will now sync with the 'servers' in /etc/ntp.conf. Once an hour it will record a little information in /etc/ntp.drift. (/etc/ntp.drift contains what it needs to know if it loses contact with all your servers and needs to "go it alone").

Of course, you'll want to make sure that this command is run on bootup, after ntpdate is run (they can't run at the same time). Here's how to do that on various operating systems:

3.1.7. What about stratum 1, 2, 3 and all that?

You don't need to specify that in the configuration file. If you list a mixture of stratum 1s, 2s, and 3s ntpd will do the right thing. Your stratum is determined dynamically based on what you've synced to. You don't need to worry about this. However, if you want to know more, there is info in the documentation.

3.1.8. Check your work.

ntpdc is a command that lets you talk to your ntpd (just like lp has lpc, ntpd has ntpdc). It has a zillion features, but the one you really need to know is:

3.1.9. Running NTP on many machines in a network.

If you have a lot of machines that need to be kept in sync, it is rude to point them all at public NTP servers. It's also a waste of your internet bandwidth. A much better solution is to set up either one or at least four NTP servers on your network that point to public NTP servers, then point all your other machines at these NTP servers. This greatly reduces the amount of load you put on the public NTP servers.

At my company, we have four NTP servers: ntp1.mycompany.com, ntp2.mycompany.com, ntp3.mycompany.com, and ntp4.mycompany.com. Those are actually aliases ("CNAME" in DNS) that point to the four machines that I want everyone to use for NTP service. We do another trick that makes the aliases point to different hosts outside our firewall. That way the same configuration file works if a machine is connected inside or outside our firewall.

These four NTP servers need to have a custom configuration, that includes each other:

I find that it is easier to have the exact same file on both of these servers. That means that each of them will try to sync with themselves. Luckily, this is ok. NTP will realize that its talking to itself and do the right thing (ignore itself).