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


Set the system default time zone:



Detect if sudo is available (“command” is used if not):

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
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'



Categories: Setup


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.