cturra/docker-ntp

no server suitable for synchronization found

discorogge opened this issue · 4 comments

Herro.

Nice repo, want to use for my NOTnet and to keep the google IOT to spam google.ntp all the time
Got this container up and running about a week and can't get the server to synq.

I do this:
ntp:
image: cturra/ntp:latest
container_name: ntp
restart: always
ports:
- 123:123
links:
- pihole
environment:
- NTP_SERVERS=time.cloudflare.com
- LOG_LEVEL=0

And open ufw 123/udp so my whole network can use this.

Doing some commands to check if it functions according to readme
Been trying this through my ISP and ovpn with no luck.

->

$ ntpdate -q 127.0.0.1
23 Nov 18:11:18 ntpdate[17102]: no server suitable for synchronization found

$ docker exec ntp chronyc tracking
Reference ID : 00000000 ()
Stratum : 0
Ref time (UTC) : Thu Jan 01 00:00:00 1970
System time : 0.000000000 seconds fast of NTP time
Last offset : +0.000000000 seconds
RMS offset : 0.000000000 seconds
Frequency : 0.000 ppm slow
Residual freq : +0.000 ppm
Skew : 0.000 ppm
Root delay : 1.000000000 seconds
Root dispersion : 1.000000000 seconds
Update interval : 0.0 seconds
Leap status : Not synchronised

$ docker exec ntp chronyc sources
MS Name/IP address Stratum Poll Reach LastRx Last sample

===============================================================================
why is this emty ? :/

$ docker logs -f ntp
2022-11-23T16:57:59Z chronyd version 4.1 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP -SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 -DEBUG)
2022-11-23T16:57:59Z Disabled control of system clock
2022-11-23T16:57:59Z Could not read valid frequency and skew from driftfile /var/lib/chrony/chrony.drift

Well i found 1 problem, ntp container doesn't seem to care about the pihole->unbound container since I guess I never specify DNS in the compose file. So it did not understand where time.cloudfare.com was located.

Updated ntp_server to cloudfares IP instead and now :

$ docker exec ntp chronyc sources
MS Name/IP address Stratum Poll Reach LastRx Last sample

===============================================================================

^? 104.16.133.229 0 7 0 - +0ns[ +0ns] +/- 0ns

I still has problems when checking my log tho ?

$ docker logs -f ntp
2022-11-23T18:01:50Z chronyd version 4.1 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP -SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 -DEBUG)
2022-11-23T18:01:50Z Disabled control of system clock
2022-11-23T18:01:50Z Could not read valid frequency and skew from driftfile /var/lib/chrony/chrony.drift

and still no synq upstream.
$ ntpdate -q 127.0.0.1
23 Nov 19:04:54 ntpdate[33886]: no server suitable for synchronization found

sorry to hear you having a rough time getting this to work for you.

i've reconfigured my container to be identical to your (minus your pihole setup) and do not seem to be running into the same issues as you. here are some snap shots of what it looks like in my environment:

docker-compose.yaml

version: "3.9"

services:
  ntp:
    image: cturra/ntp:latest
    container_name: ntp
    restart: unless-stopped
    ports:
      - 123:123/udp
    environment:
      - NTP_SERVERS=time.cloudflare.com
      - LOG_LEVEL=0

launching the container

$> docker compose up -d ntp
[+] Running 4/4
 ⠿ ntp Pulled                                                                                                                                                                                                                                                                                                                                                                                                                          2.5s
   ⠿ 59bf1c3509f3 Already exists                                                                                                                                                                                                                                                                                                                                                                                                       0.0s
   ⠿ 7b50b92aedb4 Pull complete                                                                                                                                                                                                                                                                                                                                                                                                        0.7s
   ⠿ 61038a069dce Pull complete                                                                                                                                                                                                                                                                                                                                                                                                        0.8s
[+] Running 1/1
 ⠿ Container ntp  Started

logs after first launch

$> docker logs -f ntp
2022-11-23T18:31:13Z chronyd version 4.1 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP -SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 -DEBUG)
2022-11-23T18:31:13Z Disabled control of system clock
2022-11-23T18:31:13Z Could not read valid frequency and skew from driftfile /var/lib/chrony/chrony.drift
2022-11-23T18:31:21Z Selected source 162.159.200.123 (time.cloudflare.com)

sources details

$> docker exec ntp chronyc -N sources
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* time.cloudflare.com           3   6    37    15    +47us[ +146us] +/-   25ms

tracking details

$> docker exec ntp chronyc tracking
Reference ID    : A29FC87B (time.cloudflare.com)
Stratum         : 4
Ref time (UTC)  : Wed Nov 23 18:33:31 2022
System time     : 0.002261675 seconds fast of NTP time
Last offset     : -0.000567445 seconds
RMS offset      : 0.000567445 seconds
Frequency       : 4.649 ppm slow
Residual freq   : -0.101 ppm
Skew            : 30.074 ppm
Root delay      : 0.047541384 seconds
Root dispersion : 0.002129665 seconds
Update interval : 64.3 seconds
Leap status     : Normal

query ntp server from local machine

$> ntpdate -q 127.0.0.1
server 127.0.0.1, stratum 4, offset -0.002389, delay 0.02588
23 Nov 10:35:41 ntpdate[15525]: adjust time server 127.0.0.1 offset -0.002389 sec

i'm wondering if there's something going on with your pihole that might be swallowing the dns requests to time.cloudflare.com? for what it's worth, i also have a pihole in my environment and am not seeing issues with this happening.

keep me posted on what you might discover as you bang away at this and i hope i was a little bit helpful with my response.

Thank you for a fast reply.

Very interesting indeed.

I purged my ntp container and build it with ./build -> ./run and that made the container query properly.

I can't find what those script do that docker-compose didnt but however, restarting my docker-compose stack after running your scripts fixed the problems .

Container is now working as expected. Cheers.
,👍

thanks for the update and i'm glad that you got everything sorted out 🥳