Configuring an NTP server using Debian 13

Configuring a NTP server can be a great help for your local network. Debian comes with a built in package called ntpsec and confiruing it is relatively straight forward.

To install the package run the following command:

sudo apt update && sudo apt install ntpsec -y

Next copy the configuration file so you have an original backup:

sudo cp /etc/ntpsec/ntp.conf /etc/ntpsec/ntp.original

Now edit the ntp.conf file:

sudo vi /etc/ntpsec/ntp.conf

edit the file commenting out ntp settings and add the swiss pool (for me since I am in Switzerland, you can of course pick your own, you can find an overview here of available public ntp servers: https://www.ntppool.org/en/)

# pool 0.debian.pool.ntp.org iburst
# pool 1.debian.pool.ntp.org iburst
# pool 2.debian.pool.ntp.org iburst
pool ch.pool.ntp.org iburst

and

restrict 10.0.0.0/8             # Allow campus access

restrict 192.168.0.0/16         # Allow WLAN access

restrict ch.pool.ntp.org        # Allow access

Write the file and exit

Run the following to enable the NTP service and start it:

sudo systemctl enable ntpsec

sudo systemctl start ntpsec

 

To check that everything is working you can use the following commands:

timedatectl

which after around 5 minutes gives you an output like this (before 5 minutes the System clock synchronized may show “no”):

or

ntpq -c sysinfo

That shows you the NTP server you are connected to, what Stratum (delay) you have: