NTP Network Time Protocol How To

From RidgeRun Developer Wiki
Revision as of 17:33, 7 March 2014 by Spalli (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Most of the text in this How to is taken from the massively documented NTP package.

Overview

The Network Time Protocol (NTP) is widely used to synchronize a computer to Internet time servers. It can also be used as a server for dependent clients. It provides accuracies typically less than a millisecond on LANs and up to a few milliseconds on WANs.

Client / Server Configuration

Client/server mode is the most common configuration in the Internet today. It operates in the classic remote-procedure-call (RPC) paradigm with stateless servers and stateful clients. In this mode a host sends a client (mode 3) request to the specified server and expects a server (mode 4) reply at some future time. In some contexts this would be described as a "pull" operation, in that the host pulls the time and related values from the server.

Server Configuration

For a Ubuntu host acting as an NTP server, typically nothing needs to be done, beyond grabbing the IP address.

Do verify ntpd is running:

pgrep ntpd

If a number is returned (the PID for the ntpd daemon), then your configuration is correct.


Client Configuration

A target device is configured in client mode as follows

NTP_SERVER=10.111.0.3

echo "server $NTP_SERVER" > /etc/ntp.conf
echo "statsdir /tmp/ntp_statistics" >> /etc/ntp.conf
echo "driftfile /tmp/ntp_drift" >> /etc/ntp.conf
echo "iburst" >> /etc/ntp.conf
chmod ugo+r /etc/ntp.conf

echo "ntp             123/tcp" >> /etc/services
echo "ntp             123/udp >> /etc/services