Network Time Protocol (NTP) is a protocol used to help synchronize your computer systems clocks with an accurate time source. "Stratum 1" (NTP sites that use an atomic clock for timing) and "Stratum 2" (NTP sites that have slightly less accurate time sources) sites that allow the general public to synchronize with them. You should have at least one server on your network be the local time server for all your other devices (routers, computers, etc), this makes the correlation of system events on different systems much easier. You should also use 3 or more external time servers for your local NTP server.
NTP version 3 is an internet draft standard, formalized in RFC 1305. NTP version 4 is a significant revision of the NTP standard, and is the current development version, but has not been formalized in an RFC. Simple NTP (SNTP) version 4 is described in RFC 2030.
To learn more about NTP and how to configure and use it check out ntp.org.
Don't confuse the above or below with OpenNTPD from the OpenBSD group. Both are an implementation of the Network Time Protocol. They do many of the same things. But they use different looking config files and command options.
Useful programs that work with NTP
* ntpd - Network Time Protocol (NTP) daemon
* ntpq - standard NTP query program
* ntpdc - special NTP query program
* ntpdate - set the date and time via NTP
* ntptrace - trace a chain of NTP servers back to the primary source
* tickadj - set time-related kernel variables
* ntptime - read kernel time variables
* ntp-keygen - generate public and private keys
* ntpdsim - Network Time Protocol (NTP) simulator
The configuration file below is an example of an NTP configuraiton file. Don't confuse this with an OpenNTPD config file. This config file is usually located in the file /etc/ntp.conf.
# ntpd will use syslog() if logfile is not defined #logfile /var/log/ntpd driftfile /var/lib/ntp/ntp.drift statsdir /var/log/ntpstats/ # Extra stats (not needed if you dont want stats) statistics loopstats peerstats clockstats filegen loopstats file loopstats type day enable filegen peerstats file peerstats type day enable filegen clockstats file clockstats type day enable ## Allow internel network restrict 127.0.0.1 restrict 192.168.0.0 mask 255.255.255.0 notrust nomodify notrap ## Example of local time server to query #server 10.0.10.10 #restrict 10.0.10.10 mask 255.255.255.255 nomodify notrap noquery ## Example of external servers to query server ntp0.cornell.edu server ntp-1.ece.cmu.edu server ntp-2.ece.cmu.edu server clock-1.cs.cmu.edu server cuckoo.nevada.edu server sundial.columbia.edu server time-b.nist.gov server time-c.timefreq.bldrdoc.gov server tock.usno.navy.mil ## Restrict the outsite servers we are quering restrict ntp0.cornell.edu mask 255.255.255.255 nomodify notrap noquery restrict ntp-1.ece.cmu.edu mask 255.255.255.255 nomodify notrap noquery restrict ntp-2.ece.cmu.edu mask 255.255.255.255 nomodify notrap noquery restrict clock-1.cs.cmu.edu mask 255.255.255.255 nomodify notrap noquery restrict cuckoo.nevada.edu mask 255.255.255.255 nomodify notrap noquery restrict sundial.columbia.edu mask 255.255.255.255 nomodify notrap noquery restrict time-b.nist.gov mask 255.255.255.255 nomodify notrap noquery restrict time-c.timefreq.bldrdoc.gov mask 255.255.255.255 nomodify notrap noquery restrict tock.usno.navy.mil mask 255.255.255.255 nomodify notrap noquery
OpenNTPD is a FREE, easy to use implementation of the Network Time Protocol. It provides the ability to sync the local clock to remote NTP servers and can act as NTP server itself, redistributing the local clock. The install below is an example install on OpenBSD. OpenBSD comes with OpenNTPD installed.
1. Create /etc/ntpd.conf if needed. Copy the info from below into the file and edit to suit your needs.
#################################### # OpenNTPD http://www.openntpd.org # #################################### # $OpenBSD: ntpd.conf,v 1.7 2004/07/20 17:38:35 henning Exp $ # sample ntpd configuration file, see ntpd.conf(5) # Addresses to listen on (ntpd does not listen by default) listen on 192.168.0.1 # sync to a single server #server ntp.example.org # use a random selection of 8 public stratum 2 servers # see http://twiki.ntp.org/bin/view/Servers/NTPPoolServers servers pool.ntp.org
2. Edit the line in /etc/rc.conf and set it to ntpd_flags="-s" so it starts on reboot and syncs the time immediately at startup.
3. Start it by running the command "ntpd -s". Check /var/log/daemon for any errors.