Linux: Setup ntp server

Hi,

linux can, of course 🙂 , act as an ntp server.

For debian 9 the following steps are necessary.

Install requiered packages

root@debdev ~ # apt-get install ntp

Configure the time server to synchronize time from. For Germany I recommend to use the NTP Server from the “physikalisch-technische Bundesanstalt” and Telekom/t-online. Insert

pool ptbtime1.ptb.de iburst
pool ptbtime2.ptb.de iburst
pool ntp1.t-online.de iburst

and remove the preconfigured ones.

By default the ntp answers to all clients. If you want to restrict the computer who can contact your server add

restrict default ignore
restrict -6 default ignore

to your /etc/ntp.conf.
also ensure that this lines are set

restrict -4 default kod notrap nomodify nopeer noquery limited
restrict -6 default kod notrap nomodify nopeer noquery limited

means by default only allow ntp queries and no server status information.
Then you have to add restriction entries for all subnets which can send time queries including server status (noquery not set)

restrict 192.168.254.0 mask 255.255.255.0 nomodify notrap nopeer

and if another time server should taken its time from your time servers

server 192.168.200.6
restrict 192.168.200.6 nomodify notrap nopeer noquery


Enable and start ntpd

root@debdev ~ # systemctl enable ntp
root@debdev ~ # systemctl start ntp

Check from Windows

D:\> w32tm /stripchart /computer:192.168.254.6

or from linux

root@debdev ~ #  apt-get install ntpdate
root@debdev ~ #  ntpdate -qv 192.168.254.6

Michael

Leave a Reply Cancel reply