# ntpd
ntpd (NTP daemon) is the reference implementation of the [[Network Time Protocol (NTP)]], originally written by [[David Mills]] at the University of Delaware. It has been the standard NTP daemon on Unix-like systems for decades, distributed as part of the ntp.org reference implementation package.
## How It Works
ntpd runs as a background daemon that continuously disciplines the system clock by exchanging time packets with configured NTP servers. It maintains a drift file to track the system clock's frequency error and applies gradual corrections (slewing) to keep the clock accurate. By default, ntpd will only step the clock (make an abrupt adjustment) if the offset exceeds 128 milliseconds during initial startup, and refuses to step afterward — exiting instead if the offset grows too large.
## Key Characteristics
- **Mature and well-tested**: Decades of production use across all major Unix platforms
- **Full NTP feature set**: Supports symmetric, broadcast, multicast, and manycast modes
- **Autokey authentication**: Supports both symmetric key and Autokey (public key) authentication
- **Reference clock support**: Can interface directly with GPS receivers, radio clocks, and other hardware time sources via dedicated driver interfaces
- **Slow convergence**: Takes longer than [[Chrony]] to initially synchronize, especially after a reboot or network interruption
## Configuration
The main configuration file is typically `/etc/ntp.conf`.
```conf
# Use public NTP pool servers
pool pool.ntp.org iburst
# Drift file to store frequency offset
driftfile /var/lib/ntp/drift
# Access control - restrict by default, allow localhost
restrict default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
# Log file
logfile /var/log/ntp.log
```
## Common Commands
```bash
# Query NTP peers and their status
ntpq -p
# Show synchronization status
ntpstat
# Force immediate time check
ntpdate -q pool.ntp.org
# Service management
sudo systemctl status ntpd
sudo systemctl start ntpd
sudo systemctl enable ntpd
```
## ntpd vs Chrony
While ntpd remains widely deployed, [[Chrony]] has replaced it as the default on most modern Linux distributions (RHEL 7+, Fedora, [[Arch Linux]]) because Chrony synchronizes faster, handles intermittent connectivity better, and performs well in virtualized environments. ntpd is still preferred in scenarios requiring broadcast/multicast NTP modes or direct reference clock hardware interfaces.
## References
- https://www.ntp.org/
- https://en.wikipedia.org/wiki/Ntpd
- https://www.eecis.udel.edu/~mills/ntp.html
## Related
- [[Network Time Protocol (NTP)]]
- [[Chrony]]
- [[David Mills]]
- [[systemd]]
- [[Arch Linux]]