Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
docker_notes:ntp [2025-11-09 Sun wk45 11:26] – [ntp servers] baumkpdocker_notes:ntp [2025-11-14 Fri wk46 22:12] (current) – [chronyc] baumkp
Line 11: Line 11:
 ntp servers can be checked using the ''ntpdate'' command, which can be loaded in Debian with ''sudo apt install ntpsec-ntpdate'' ntp servers can be checked using the ''ntpdate'' command, which can be loaded in Debian with ''sudo apt install ntpsec-ntpdate''
  
 +++++List of local ntp servers|
 Ranked by testing with ''sudo ntpdate -q {ntp servername/ip}'' Ranked by testing with ''sudo ntpdate -q {ntp servername/ip}''
 ^ sync ^ accuracy ^ server ^ ip address ^ stratum ^ leap status ^ ^ sync ^ accuracy ^ server ^ ip address ^ stratum ^ leap status ^
 | +0.018040 | +/- 0.026068 | nets.org.sg | 129.126.239.115 | s1 | no-leap | | +0.018040 | +/- 0.026068 | nets.org.sg | 129.126.239.115 | s1 | no-leap |
-| +0.020117 | +/- 0.027653 | server 3.au.pool.ntp.org | 103.126.53.123 | s2 | no-leap |+| +0.020117 | +/- 0.027653 | 3.au.pool.ntp.org | 103.126.53.123 | s2 | no-leap |
 | +0.020819 | +/- 0.027315 | 0.au.pool.ntp.org | <wrap hi>139.99.135.247</wrap> | s2 | no-leap | | +0.020819 | +/- 0.027315 | 0.au.pool.ntp.org | <wrap hi>139.99.135.247</wrap> | s2 | no-leap |
 | +0.050351 | +/- 0.064718 | 1.au.pool.ntp.org | 180.150.8.191 | s1 | no-leap | | +0.050351 | +/- 0.064718 | 1.au.pool.ntp.org | 180.150.8.191 | s1 | no-leap |
Line 31: Line 32:
 | +2.002964 | +/- 2.027214 | 2.au.pool.ntp.org | <wrap hi>112.213.32.219</wrap> | s2 | no-leap | | +2.002964 | +/- 2.027214 | 2.au.pool.ntp.org | <wrap hi>112.213.32.219</wrap> | s2 | no-leap |
 | +0.154351 | +/- 0.184338 | 3.au.pool.ntp.org | 159.196.40.161 | s1 | no-leap | | +0.154351 | +/- 0.184338 | 3.au.pool.ntp.org | 159.196.40.161 | s1 | no-leap |
 +Taken 2025-11-09 11:15
  
 +Based upon the duplication of ip address for different domain names and changing ip addresses on same domain names it looks like the ip address are rolled to different servers to balance load. 
 +++++
  
 +=====chronyc=====
 +chronyc can be used to query chronyd.  The following are some key queries.  Note chrony help will provide a list of available commands.
 +  *''sources -v'' will list information about the current sources
 +  *''tracking'' Display system time information
 +  *''nptdata'' display information about last valid measurement
 +  *''activity'' check how many NTP sources are online/offline
 +  *''serverstats'' Display statistics of the server
 +  *''authdata -v'' Display information about authentication
 +
 +++++/etc/chrony/chrony.conf|
 +<code># default config
 +
 +=====docker chrony=====
 +++++Dockerfile|
 +<code>FROM alpine:latest
 +
 +RUN apk update && \
 +apk --no-cache add \
 +chrony
 +
 +EXPOSE 123/udp
 +
 +
 +#ENTRYPOINT [ "/bin/sh" ]
 +ENTRYPOINT [ "/usr/sbin/chronyd", "-d" ]
 +#ENTRYPOINT [ "/usr/sbin/chronyd", "-d", "-s" ]
 +</code>
 +++++
 +
 +++++docker-compose.yml|
 +<code>---
 +services:
 +  chrony:
 +    build: ./
 +    image: chrony:latest
 +    tty: true
 +    stdin_open: true
 +    container_name: chrony
 +    restart: 'always' # always | unless-stopped | no | on-failure [:max-retries]
 +
 +#    volumes:
 +#      - '/mnt/docker_store/kea/.config:/app/'
 +#      - '/mnt/docker_store/kea/.config/log:/var/log/kea'
 +#    network_mode: host
 +
 +    cap_add:
 +      - SYS_TIME
 +
 +#    command: /bin/sh
 +</code>
 +++++
 +
 +  *''docker exec -ti chrony /bin/sh'' to get shell access to container
 +
 +pool pool.ntp.org iburst
 +initstepslew 10 pool.ntp.org
 +driftfile /var/lib/chrony/chrony.drift
 +rtcsync
 +cmdport 0</code>++++
 +
 +=====Reference=====
 +  *[[https://www.bodet-time.com/resources/blog/1882-stratums-in-the-ntp-protocol-understanding-the-hierarchy-of-servers.html|STRATUMS IN THE NTP PROTOCOL: Understanding the hierarchy of servers]]
 +  *[[https://chrony-project.org/|chrony]]
 +  *[[https://github.com/cturra/docker-ntp/tree/main|cturra/ntp]] (crony docker example)
 +  *[[https://www.tecmint.com/install-chrony-in-centos-ubuntu-linux/|How to Install and Use Chrony in Linux]]
 +  *[[https://krython.com/post/configuring-ntp-server|configuring-ntp-server]]
 +  *[[https://wiki.archlinux.org/title/Chrony|Arch chrony]]
 +  *[[https://www.golinuxcloud.com/configure-chrony-ntp-server-client-force-sync/|Steps to configure Chrony as NTP Server & Client (CentOS/RHEL 8)]]
 +  *[[https://documentation.ubuntu.com/server/how-to/networking/serve-ntp-with-chrony/|How to serve the Network Time Protocol with Chrony]]
 +  *[[https://www.howtouselinux.com/post/using-chrony-for-ntp-on-linux|The Essential Guide to Using Chrony for NTP on Linux]]
  
 <- docker_notes:nginx-php-notes|Back ^ docker_notes:index|Start page ^ docker_notes:misc|Next -> <- docker_notes:nginx-php-notes|Back ^ docker_notes:index|Start page ^ docker_notes:misc|Next ->