NTP (acronym of Network Time Protocol) is a communication protocol conceived to synchronize computer clocks worldwide to the International Atomic Time (TAI).
This howto is tested on:
- Debian 10.0 Buster
Settings
Set the system default time zone:
timeZone='Europe/Paris'
Installation
Detect if sudo is available (“command” is used if not):
cmdProxy='command'
command type -f 'sudo' &>'/dev/null' && cmdProxy='sudo'
NTP client configuration
Before system.d generalization, using NTP required to install additional software. System.d timesyncd service now provide the NTP functionality.
Show time synchronization status:
command timedatectl 'timesync-status'
Enable NTP synchronization:
${cmdProxy} timedatectl 'set-ntp' 'true'
Set system default time zone:
${cmdProxy} timedatectl 'set-timezone' "${timeZone}"
Further configuration options are available in “/etc/systemd/timesyncd.conf”. It is possible to set a different NTP source, but default settings are generally fine.
For more information on system.d time sync service, read the related man pages:
# Time Sync service documentation.
command man 'systemd-timesyncd.service'
# /etc/system.d/timesyncd.conf documentation.
command man 'timesyncd.conf'
NTP server configuration
Setup a NTP server only if you really need it. For most use-cases, a NTP client is sufficient.
Install the software:
${cmdProxy} apt install 'ntp'
For better security, limit the NTP server to listen only for localhost connections:
${cmdProxy} tee -a '/etc/ntp.conf' <<< "
# Limit listening to local ips.
interface ignore wildcard
interface listen 127.0.0.1
interface listen ::1"
Synchronize the system clock to the atomic time, even if the time gap is big, and by stop and starting the server, reload its configuration:
${cmdProxy} systemctl 'stop' 'ntp'
${cmdProxy} ntpd --panicgate --quit
${cmdProxy} systemctl 'start' 'ntp'
Bibliography
- Expert Network Time Protocol: An Experience in Time with NTP.
- Computer Network Time Synchronization: The Network Time Protocol on Earth and in Space.
- NTP Security: A Quick-Start Guide.
- UNIX and Linux System Administration Handbook.
- Linux Bible.
Thanks
- Thanks to Grawok (fr) for Réglage automatique de l’heure avec NTP – utilisation du pool.ntp.org pour Debian et Ubuntu (fr).
- Thanks to NTP (fr) authors on Wiki Debian francophone (fr).
- Thanks to NTP (en) authors on Debian Wiki (en).
- Thanks to Meinberg Knowledge Base (en) for NTP Basics (en).
0 Comments