Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save christopherpaquin/69b8f59f05c3d13278e7a2568dfa5cb3 to your computer and use it in GitHub Desktop.

Select an option

Save christopherpaquin/69b8f59f05c3d13278e7a2568dfa5cb3 to your computer and use it in GitHub Desktop.
###############################################################################
# Chrony configuration
#
# Purpose:
# - Discipline system time using a USB GPS receiver via gpsd (NMEA-only)
# - No PPS available, so accuracy is milliseconds (not microseconds)
# - Act as a low-priority NTP server for the local network
#
# Notes:
# - Chrony always operates internally in UTC
# - GPS time is provided by gpsd over a UNIX socket
###############################################################################
#------------------------------------------------------------------------------
# Include additional configuration snippets
#------------------------------------------------------------------------------
# Allows drop-in configuration files (not required, but standard on Ubuntu)
confdir /etc/chrony/conf.d
###############################################################################
# Debug / observability
###############################################################################
# Where chrony writes its own detailed log streams
logdir /var/log/chrony
# Enable detailed logs:
# - tracking: disciplined clock state (offset/freq/skew, etc.)
# - measurements: raw samples from sources (very useful for refclocks)
# - statistics: aggregate stats per source
log tracking measurements statistics
# Log when chrony makes a clock correction bigger than the thresholds
# (units: seconds). Helps correlate “why did time jump?” events.
logchange 0.5
#------------------------------------------------------------------------------
# GPS reference clock (via gpsd)
#------------------------------------------------------------------------------
# Use gpsd's UNIX socket as a reference clock.
#
# SOCK /var/run/gpsd.sock
# - Chrony does NOT talk to the GPS device directly
# - gpsd parses NMEA and provides time samples
#
# refid GPS
# - Human-readable label shown in chronyc output
#
# poll 4
# - Poll interval = 2^4 seconds = 16 seconds
#
# precision 1e-1
# - Declare expected precision (~100 ms)
# - REQUIRED for NMEA-only GPS to avoid sample rejection
#
# delay 0.2
# - Account for USB + NMEA sentence latency
#
# trust
# - Explicitly allow chrony to accept this low-precision refclock
#
#refclock SOCK /run/gpsd.sock refid GPS poll 4 precision 1e-1 delay 0.2 trust prefer
refclock SHM 0 refid GPS poll 4 precision 1e-1 delay 0.2 trust prefer
#------------------------------------------------------------------------------
# Standalone operation policy
#------------------------------------------------------------------------------
# Allow chrony to discipline the system clock even if:
# - No network NTP servers are configured
# - GPS is the only available reference
#
# Advertise this host as stratum 10 to NTP clients:
# - Prevents it from being treated as an authoritative time source
# - Avoids NTP loops
# - Appropriate for NMEA-only GPS (no PPS)
#
local stratum 2
#------------------------------------------------------------------------------
# Clock stepping behavior
#------------------------------------------------------------------------------
# Allow the system clock to be stepped (jumped) instead of slewed
# if the offset is larger than 1 second, but ONLY during startup
# and only for the first 3 updates.
#
# This prevents long convergence times on boot while avoiding
# disruptive time jumps during normal operation.
#
makestep 1.0 3
#------------------------------------------------------------------------------
# Frequency drift handling
#------------------------------------------------------------------------------
# Persist the measured frequency error of the system clock.
#
# This allows chrony to:
# - Start with a good frequency estimate after reboot
# - Converge faster
# - Free-run more accurately if all time sources disappear
#
driftfile /var/lib/chrony/chrony.drift
#------------------------------------------------------------------------------
# NTP server behavior (serving time to clients)
#------------------------------------------------------------------------------
# Allow NTP clients from the local subnet to query this server
#
allow 10.1.10.0/24
# Bind NTP service explicitly to this interface/address
# (prevents listening on unintended interfaces)
#
bindaddress 10.1.10.11
#------------------------------------------------------------------------------
# Optional dynamic source handling
#------------------------------------------------------------------------------
# Allow chrony to use NTP servers provided via DHCP (if present)
#
sourcedir /run/chrony-dhcp
# Allow additional NTP source files to be added modularly
#
sourcedir /etc/chrony/sources.d
#------------------------------------------------------------------------------
# Security and key material
#------------------------------------------------------------------------------
# File containing NTP authentication keys (if used)
#
keyfile /etc/chrony/chrony.keys
# Directory used to store NTS (Network Time Security) cookies and keys
#
ntsdumpdir /var/lib/chrony
#------------------------------------------------------------------------------
# Logging
#------------------------------------------------------------------------------
# Directory where chrony logs are written
#
logdir /var/log/chrony
# Uncomment the following line to enable detailed logging:
# log tracking measurements statistics
#------------------------------------------------------------------------------
# Stability and safety controls
#------------------------------------------------------------------------------
# Prevent chrony from applying updates if clock estimates become unstable
#
maxupdateskew 100.0
# Periodically sync the system time back to the hardware RTC
# (every ~11 minutes)
#
rtcsync
#------------------------------------------------------------------------------
# Leap second handling
#------------------------------------------------------------------------------
# Obtain leap second and TAI-UTC offset information from the system
# timezone database, operating in strict UTC mode.
#
leapsectz right/UTC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment