Jump to: navigation, search

NTPD (Network Time Procokol Daemon)


The NTPD program is an operating-system daemon that sets and maintains a computer system's time in synchronization with Internet-standard time servers. It is a complete implementation of the Network Time Protocol (NTP) version 4, but retains compatibility with versions 1, 2, and 3 as defined by RFC 1059, RFC 1119, and RFC 1305, respectively. ntpd performs most computations in 64-bit floating point arithmetic and uses 64-bit fixed point operations only when necessary to preserve the ultimate precision, about 232 picoseconds. While ordinary workstations and networks cannot achieve the ultimate precision as of 2015, future processors and networks may require it.

NTPD Installation

To install NTPD package simply use the following commands:

1. Update List of Available Packages

root@iplog:~# opkg update

Example of Update Process:

Downloading http://www.iplog.eu/opkg/base/Packages.gz.
Updated source 'base'.
Downloading http://www.iplog.eu/opkg/firmware/Packages.gz.
Updated source 'firmware'.

2. Upgrade Installed Packages

root@iplog:~# opkg upgrade

3. Install NTPD Package

root@iplog:~# opkg install ntpd

Example of Package Installing:

Installing ntpd (4.2.8p9-9671.212083251) on root.
Downloading http://www.iplog.eu/opkg/base/ntpd_4.2.8p9-9671.212083251_all.ipk.
Configuring ntpd.

When the instalation is complete, start the NTP daemon by command:

root@iplog:~# /etc/init.d/S49ntp start

Note: Every time the configuration file /etc/ntp.conf is changed, restart the service S49ntp by command /etc/init.d/S49ntp restart!

Configuration Examples

This section provides several examples of the /etc/ntp.conf configuration file.

1. Standalone NTP server

The following configuration has the following features:

- Local NTP server with specified stratum 10
- No synchronization to internet NTP servers

Editing Configuration File Command:

root@iplog:~# vi /etc/ntp.conf

File content:

restrict default
#restrict source
#interface listen wildcar
# create a local NTP server
fudge stratum 10

driftfile /tmp/ntp.drift

2. With Connetion to Remote NTP Servers

The example shows the optimal configuration for the Czech Republic.

This configuration has the following features:

- Local NTP server with specified stratum 10
- Synchronization to two internet NTP servers

Editing Configuration File Command:

root@iplog:~# vi /etc/ntp.conf

File Content:

restrict default
#restrict source
#interface listen wildcard

server tik.cesnet.cz
server tak.cesnet.cz

fudge stratum 10 refid ILOG

driftfile /tmp/ntp.drift



The ntpq utility program is used to query NTP servers which implement the recommended NTP mode 6 control message format about the current state and to request changes in that state.

NTPQ Home Page


root@iplog:~# watch ntpq -p -n

NTPQ Parameters:

watch - Every 2s: ntpq -p -n
-p - Print current status
-n - Disable DNS resolving
Every 2s: ntpq -p -n                                        2019-08-01 10:00:12

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================     .ILOG.          10 l  41m   64    0    0.000    0.000   0.000
+  2 u   92  128  377   12.307    2.212   1.333
* .GPS.            1 u   20  128  377   11.039    4.785   1.630

This section is a copy from https://pthree.org/2013/11/05/real-life-ntp/.


remote – The remote server you wish to synchronize your clock with
◦ " " Discarded as not valid. It is possible that you will be unable to communicate with the remote machine (it's not online), this time source is a ".LOCL." refid time source, it's a high stratum server, or the remote server is using this computer as an NTP server.
◦ "x" Discarded by the intersection algorithm.
◦ "." Discarded by table overflow (not used).
◦ "-" Discarded by the cluster algorithm.
◦ "+" Included in the combined algorithm. This is a good candidate if the current server we are synchronizing with is discarded for any reason.
◦ "#" Good remote server to be used as an alternative backup. This is only shown if you have more than 10 remote servers.
◦ "*" The current system peer. The computer is using this remote server as its time source to synchronize the clock
◦ "o" Pulse per second (PPS) peer. This is generally used with GPS time sources, although any time source delivering a PPS will do. This tally code and the previous tally code "*" will not be displayed simultaneously.
refid – The upstream stratum to the remote server. For stratum 1 servers, this will be the stratum 0 source.
st – The stratum level, 0 through 16.
t – The type of connection.
◦ l = local reference clock
◦ u = unicast (most common)
◦ m = multicast
◦ b = broadcast
when – The last time when the server was queried for the time. Default is seconds, or "m" will be displayed for minutes, "h" for hours and "d" for days.
poll – How often the server is queried for the time, with a minimum of 8 seconds to a maximum of 36 hours. It's also displayed as a value from a power of two. Typically, it's between 64 seconds and 1024 seconds.
reach – This is an 8-bit left shift octal value that shows the success and failure rate of communicating with the remote server. Success means the bit is set, failure means the bit is not set. 377 is the highest value.
delay – This value is displayed in milliseconds, and shows the round trip time (RTT) of your computer communicating with the remote server.
offset – This value is displayed in milliseconds, using root mean squares, and shows how far off your clock is from the reported time the server gave you. It can be positive or negative.
jitter – This number is an absolute value in milliseconds, showing the root mean squared deviation of your offsets.