I am trying to get NTP working on a Raspberry Pi using ntpd. I've disabled systemd-timesyncd and installed ntp by using:
$ sudo apt-get install ntp
But after installing it, ntp
does not synchronise with any servers. After re-installing ntp, it sometimes connects to one or two servers and synchronises. But after a reset (sudo service ntp restart
), it can't connect to any server anymore.
I am using a Raspberry Pi 2 model B and a Raspberry Pi 3 model B+. It doesn't work for both devices. I also have one Raspberry Pi 3 model B which does work as expected. The Raspberry Pi's are all connected to the same network (therefore, it can't be the fault of the firewall of the network). The Raspberry Pi's run on Raspbian Buster.
Sometimes when it is synchronising correctly, I execute ntpd -p
and see that there are only one or two servers. But the Raspberry Pi that works correctly synchronises with 4+ servers. NTP worked before on the Raspberry Pi 2 model B, but it stopped working without changing anything to the system. Afterwards, I did a full reinstall of NTP, but with no success (sudo apt-get purge --autoremove ntp
). These results are with the default configuration file in /etc/ntp.conf
.
I cannot use systemd-timesyncd
because I want this system to become a server for underlying systems. systemd-timesyncd
seems to work fine though, but I need a server for < 1ms clock synchronisation between devices.
Status of NTP
Below I've placed the status of NTP and the result of ntpq -pn
The status of ntp after a restart:
pi@raspberrypi:~ $ sudo service ntp status
● ntp.service - Network Time Service
Loaded: loaded (/lib/systemd/system/ntp.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2020-04-24 14:48:10 CEST; 5s ago
Docs: man:ntpd(8)
Process: 2837 ExecStart=/usr/lib/ntp/ntp-systemd-wrapper (code=exited, status=0/SUCCESS)
Main PID: 2843 (ntpd)
Tasks: 2 (limit: 2200)
Memory: 1.0M
CGroup: /system.slice/ntp.service
└─2843 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 109:114
Apr 24 14:48:10 raspberrypi ntpd[2843]: Listen normally on 3 eth0 192.168.0.103:123
Apr 24 14:48:10 raspberrypi ntpd[2843]: Listen normally on 4 lo [::1]:123
Apr 24 14:48:10 raspberrypi ntpd[2843]: Listen normally on 5 eth0 [fe80::1ef8:d982:66ac:4214%2]:123
Apr 24 14:48:10 raspberrypi ntpd[2843]: Listening on routing socket on fd #22 for interface updates
Apr 24 14:48:10 raspberrypi ntpd[2843]: kernel reports TIME_ERROR: 0x2041: Clock Unsynchronized
Apr 24 14:48:10 raspberrypi ntpd[2843]: kernel reports TIME_ERROR: 0x2041: Clock Unsynchronized
Apr 24 14:48:11 raspberrypi ntpd[2843]: Soliciting pool server 174.138.9.187
Apr 24 14:48:12 raspberrypi ntpd[2843]: Soliciting pool server 194.5.96.30
Apr 24 14:48:13 raspberrypi ntpd[2843]: Soliciting pool server 162.159.200.123
Apr 24 14:48:14 raspberrypi ntpd[2843]: Soliciting pool server 83.162.149.224
The result of ntpq -pn
:
pi@raspberrypi:~ $ ntpq -pn
remote refid st t when poll reach delay offset jitter
==============================================================================
0.debian.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.001
1.debian.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.001
2.debian.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.001
3.debian.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.001
The result of ntpstat
:
pi@raspberrypi:~ $ ntpstat
unsynchronised
polling server every 8 s
Does anyone know the cause of NTP not synchronising with a server?
The output of sudo ntpdate -qu 0.debian.pool.ntp.org
:
pi@raspberrypi:~ $ sudo ntpdate -qu 0.debian.pool.ntp.org
server 213.136.0.252, stratum 1, offset 0.017778, delay 0.04608
server 45.159.204.28, stratum 2, offset 0.016319, delay 0.04184
server 83.98.155.30, stratum 2, offset 0.016869, delay 0.04346
server 94.228.220.14, stratum 2, offset 0.017546, delay 0.04454
24 Apr 16:23:17 ntpdate[3139]: adjust time server 213.136.0.252 offset 0.017778 sec
The configuration in /etc/ntp.conf
:
pi@raspberrypi:~ $ grep '^[^#]' /etc/ntp.conf
driftfile /var/lib/ntp/ntp.drift
leapfile /usr/share/zoneinfo/leap-seconds.list
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
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
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
Result of timedatectl status
:
pi@raspberrypi:~ $ timedatectl status
Local time: Fri 2020-04-24 16:40:05 CEST
Universal time: Fri 2020-04-24 14:40:05 UTC
RTC time: n/a
Time zone: Europe/Amsterdam (CEST, +0200)
System clock synchronized: no
NTP service: inactive
RTC in local TZ: no
date
, is the date/time accurate to within five minutes? It seems you're CEST, so whendate --utc
do you get an output that's approximately TWO hours behind your local time? As an example, it's 15:25 CEST right now, so I'd expect UTC to be 13:25.ntpq -np
? You must need to wait at 64 seconds before you'll get anything formntpq -pn
, and up to eight minutes for full synchronisation. It's looking like you cannot get to any of the chosen pool servers - you do have Internet connectivity?raspi-config
systemd-timesyncd
? Although I disabled it (added this to the post too).