Devuan: use the OpenNTPD time synchronization client

Article published the
4 minute(s) to read

This article has 728 words.
RAW source of the article: MD

Description

OpenNTPD is a service that can be used to synchronize the system clock to the time servers using the NTP .

OpenNTPD is a part the OpenBSD base system. It was ported to others OSes, as Devuan.

Installation

With the apt tool: apt install openntpd

Configuration

  • The file config is: /etc/opennptd/ntpd.conf

By default, it runs without no needed modification.

File: /etc/opennptd/ntpd.conf

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# $OpenBSD: ntpd.conf,v 1.14 2015/07/15 20:28:37 ajacoutot Exp $
# sample ntpd configuration file, see ntpd.conf(5)

# Addresses to listen on (ntpd does not listen by default)
#listen on *
#listen on 127.0.0.1
#listen on ::1

# sync to a single server
#server ntp.example.org

# use a random selection of NTP Pool Time Servers
# see http://support.ntp.org/bin/view/Servers/NTPPoolServers
#servers pool.ntp.org

# Choose servers announced from Debian NTP Pool
servers 0.debian.pool.ntp.org
servers 1.debian.pool.ntp.org
servers 2.debian.pool.ntp.org
servers 3.debian.pool.ntp.org

# use a specific local timedelta sensor (radio clock, etc)
#sensor nmea0

# use all detected timedelta sensors
#sensor *

Explanations

About options:

  • server: to target on time server, in particular.
  • servers: to targer a pool of time servers - prefer this
  • sensor: to use local timedelta sensor

Utilisation

Checks

To check the file config, use the option -n, as-is:
# openntpd -n
configuration OK

If not good, you need to review the file config.


ntpctl is the tool to control the time informations.

  • the option -s all - or -sa - is to display availables informations.

Code: shell

# ntpctl -sa
4/4 peers valid, clock unsynced, clock offset is -552.476ms

peer
   wt tl st  next  poll          offset       delay      jitter
82.64.42.185 from pool 0.debian.pool.ntp.org
    1 10  2    6s   32s         0.203ms    60.784ms    31.533ms
194.177.34.116 from pool 0.debian.pool.ntp.org
    1 10  3    9s   32s         2.000ms    54.595ms    17.411ms
212.129.10.70 from pool 0.debian.pool.ntp.org
    1 10  2    9s   33s         5.552ms    51.518ms     4.078ms
162.159.200.1 from pool 0.debian.pool.ntp.org
    1 10  3    7s   33s        -0.176ms    55.383ms    17.593ms
Info

Service

The service name is openntpd, to manage with the service.

service openntpd command

  • command is one of possibles actions on a service, as start, stop, restart.

Troubleshooting

It can happen at startup that there is a time lag. Using the option -s solve:

Code: shell

# openntpd -s -d
adjtimex returns frequency of 0.000000ppm
/var/lib/openntpd/db/ntpd.drift is empty
ntp engine ready
reply from 212.83.179.156: offset -522.890034 delay 0.054365, next query 7s
set local clock to Sat Apr 25 12:09:03 CEST 2020 (offset -522.890034s)
reply from 5.135.3.88: negative delay -522.825725s, next query 3203s
reply from 46.105.237.136: negative delay -522.823915s, next query 3197s
reply from 185.21.216.198: negative delay -522.821620s, next query 3012s
reply from 51.15.175.180: negative delay -522.821769s, next query 3010s
reply from 37.187.104.44: negative delay -522.820949s, next query 3031s
reply from 46.235.141.130: negative delay -522.816360s, next query 3274s
reply from 162.159.200.1: negative delay -522.816819s, next query 3030s
reply from 5.39.60.244: negative delay -522.816297s, next query 3254s
reply from 95.81.173.155: negative delay -522.812132s, next query 3176s
reply from 51.15.191.239: negative delay -522.810759s, next query 3017s
reply from 5.39.60.244: negative delay -522.809750s, next query 3082s
reply from 51.158.147.92: negative delay -522.805041s, next query 3250s
reply from 212.85.158.10: negative delay -522.800165s, next query 3041s
reply from 88.212.196.95: negative delay -522.784156s, next query 3179s
reply from 156.38.0.219: negative delay -522.657588s, next query 3023s
reply from 212.83.179.156: offset -0.004612 delay 0.049539, next query 7s
reply from 212.83.179.156: offset -0.007646 delay 0.049241, next query 9s
peer 212.83.179.156 now valid

Constraint

It seems the constraint option is not available!

Info

peer not valid

You have this message:

Code: shell

   wt tl st  next  poll          offset       delay      jitter
95.81.173.8 from pool 0.debian.pool.ntp.org
    1  4  2    8s    9s             ---- peer not valid ----

Wait a little for the ntp queries to be returned.
Normally at the next query, this should no longer be the case.

Otherwise, check that the NTP servers registered in the file config are well written, reachable and functional.

Documentation

The NTP protocol is defined in:

RFC 1305

IETF Tools
HTML, PDF, TXT
RFC Editor
HTML, PDF, TXT

RFC 5905

IETF Tools
HTML, PDF, TXT
RFC Editor
HTML, PDF, TXT

Manpages

Please, read the manpages: