Warning: THE VOID WIKI IS DEPRECATED. It is no longer being maintained, contains outdated and incorrect information, and will eventually be shut down. Please refer to the Void Handbook, https://docs.voidlinux.org/, for the official documentation. If you can't find the information you're seeking, please raise an issue at https://github.com/void-linux/void-docs/issues

NTP

From Void Linux Wiki
Jump to navigation Jump to search

By default Void does not provide an NTP daemon, so in order to have accurate network-synced time, one must be installed.

The following implementations of NTP are available in Void: OpenNTPD, Network Time Protocol daemon, Chrony and Busybox.

OpenNTPD

OpenNTPD provides the ability to sync the local clock to remote NTP servers and can act as NTP server itself. It is part of the OpenBSD project.

Installation

# xbps-install -S openntpd
# ln -s /etc/sv/openntpd/ /var/service/

Configuration

To configure OpenNTPD, you need to edit /etc/ntpd.conf. See ntpd.conf(5) for all available options. After configuring, check the configuration file for validity by executing:

$ ntpd -n

Network Time Protocol daemon

ntp is the reference implementation of the NTP protocol. NTP can be run both as a client and as a server.

Installation

# xbps-install -S ntp
# ln -s /etc/sv/isc-ntpd/ /var/service/
# ln -svf /etc/sv/ntpd/ /var/service/ (optional)
# sv up isc-ntpd

Configuration

ntpd uses the same configuration as OpenNTPD.

# vi /etc/ntp.conf 
# With the default settings below, ntpd will only synchronize your clock.
#
# For details, see:
# - the ntp.conf man page
# - http://support.ntp.org/bin/view/Support/GettingStarted
#
# Select three geolocalized NTP public servers; see http://www.pool.ntp.org/
server 0.pool.ntp.org iburst
server 1.pool.ntp.org iburst
server 2.pool.ntp.org iburst

# Only allow read-only access from localhost
restrict default noquery nomodify nopeer
restrict 127.0.0.1
restrict ::1

# Location of drift and log files
driftfile /var/db/ntpd/drift

and finally, update via root:

# ntpd -u $USER

in case if you want to sync with the hardware clock:

# hwclock --systohc --localtime
# date (for check the updated time)

Chrony

chrony is a NTP client and server that is roaming friendly and designed specifically for systems that are not online all the time.

Installation

# xbps-install -S chrony
# ln -s /etc/sv/chronyd/ /var/service/

Configuration

See chrony.conf(5)

Busybox

busybox combines tiny versions of many common UNIX utilities into a single small executable, one of the many utilities it provides is an NTP daemon.

Installation

# xbps-install -S busybox
# ln -s /etc/sv/busybox-ntpd/ /var/service/

Configuration

See ntp.conf(5)

The ntpd service

The symlink /etc/sv/ntpd will point to the NTP service in order of installation date. And can be used in place of the NTP daemon's name, allowing switching between NTP implementations without enabling and disabling their services.