Installation of ntp server on debian.
Most Linux system have ntp installed by default if the service is not there install the package
sudo apt install ntp
sudo service ntp start
After installing the service you can point your devices to use the server right away using the default config. However you need to make sure the server is synchronized first. If the server is synched there will be on one of the listed peer in the output displayed below in my case the local server is chosen. If there are no wait for some time (can take up to 10 minutes)
root@eve-ng:~# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*LOCAL(0) .LOCL. 5 l 46 64 377 0.000 0.000 0.000
ntp.dts.mg 10.8.3.5 2 u 19 1024 1 95.742 -31090. 0.000
ntp2.inx.net.za .XFAC. 16 u 69h 1024 0 0.000 0.000 0.000
41.223.244.123 238.72.153.243 2 u 82 1024 1 111.130 -31067. 0.000
Configuration
If you want to change the ntp pools and server used to synchronize time, edit the ntp configuration file /etc/ntp.conf
Below is the configuration on my server where I have specified the pool to use from ntp.pool.org also I have directed the server to use its local time as the source instead of the time from the pools. I have configured the allowed clients from 10.10.1.0/24 finally I have configured the ntp keys that clients will use to verify the association with this server using key 1 which is an md5 (M) key workbook. Keys are stored on a different file /etc/ntp.keys
root@eve-ng:~# cat /etc/ntp.conf
restrict -4 default kod notrap nomodify nopeer noquery limited
restrict -6 default kod notrap nomodify nopeer noquery limited
restrict 127.0.0.1
restrict ::1
restrict source notrap nomodify noquery
restrict 10.10.1.0 mask 255.255.255.0 nomodify notrap
server 0.africa.pool.ntp.org
server 1.africa.pool.ntp.org
server 2.africa.pool.ntp.org
server 3.africa.pool.ntp.org
# local clock
server 127.127.1.0 prefer
fudge 127.127.1.0
driftfile /var/lib/ntp/ntp.drift
keys /etc/ntp.keys
trustedkey 1
Edit the keys file to add the keys
root@eve-ng:~# cat /etc/ntp.keys
1 M workbook
After configuration changes restart the servicesudo service ntp restart