< All posts

May 10, 2020, 9:04 p.m.

NTP Server Debian 10

A quick post on setting up a local NTP server with Debian 10

Install the ntp package:

$ sudo apt install ntp

Configure ntp to use for IPv4 only:

$ sudo nano /etc/default/ntp

NTPD_OPTS='-g -4'

Configure ntp servers and restrictions:

$ sudo nano /etc/ntp.conf


# You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example
server ntp.pagasa.dost.gov.ph


# pool.ntp.org maps to about 1000 low-stratum NTP servers.  Your server will
# pick a different set every time it starts up.  Please consider joining the
# pool: <http://www.pool.ntp.org/join.html>
#pool 0.debian.pool.ntp.org iburst
#pool 1.debian.pool.ntp.org iburst
#pool 2.debian.pool.ntp.org iburst
#pool 3.debian.pool.ntp.org iburst

# Example allow access from 192.168.1.0/24 and 172.16.1.0/24 clients
restrict 192.168.1.0 mask 255.255.255.0  nomodify notrap nopeer
restrict 172.16.1.0 mask 255.255.255.0 nomodify notrap nopeer

Allow access to 123/UDP on your firewall.
Sample: $ sudo iptables -A udp_inbound -p UDP -s 0/0 --dport 123 -j ACCEPT

Test ntp server:

$ ntpq -p

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 121.58.193.100  .GPS.            1 u   22   64    1  124.686  -145.97   0.000

Setting time to your client (requires ntpdate package):

$ sudo ntpdate 172.16.1.1

10 May 21:09:41 ntpdate[1519]: step time server 172.16.1.1 offset 0.814652 sec

Replace 172.16.1.1 to your NTP server IP Address.

References:

https://kifarunix.com/setup-ntp-server-using-ntpd-on-debian-10-buster/
https://www.tecmint.com/install-and-configure-ntp-server-client-in-debian/