Ntp
Network Time Protocol, synchronize local clock to remote.
To use ntpq the firewall should be open for traffic to the localhost.
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
ip6tables -A INPUT -i lo -j ACCEPT
ip6tables -A OUTPUT -o lo -j ACCEPT
When using an NTP-server pool like pool.ntp.org ( 0.<country>.pool.ntp.org etc.) make sure you refresh the peers every now and than. Only when ntp is started the hosts are selected, when they leave the pool ntp will not automatically select another.
- Very secure setinngs in ntp.conf
restrict -4 default kod nomodify notrap nopeer noquery restrict -6 default kod nomodify notrap nopeer noquery
- ntpq
- CLI interface to query the ntp status.
- peer
- Show peers
- ass
- Show associations (details of peers)
- pstat <assid>
- Show status of a association
- ntpdate -q <server>
- Get date from <server> without doing any update
systemd-timesyncd
systemd-timesyncd is a lightweight client-only ntp implementation.
By default configuration from DHCP is used. Additional configuration can be added to /etc/systemd/timesyncd.conf
NTP=<space separated list of NTP-servers> FallbackNTP=<space separated list of NTP-servers>
Only 1 server is used, the server lists are polled one by one until one responds.
- timedatectl show
- Show status of the synchronization
- timedatectl show-timesync
- Detailed status of the synchronization
- timedatectl timesync-status
- More detailed status of the synchronization
- systemctl status systemd-timesyncd
- The status of the daemon
- systemctl restart systemd-timesyncd
- Restart the daemon on configuration changes, reload is not supported.
If you want to use ntp instead of timesyncd e.g. because you want to run a ntp server use:
systemctl disable systemd-timesyncd.service
apt install ntp
The NTP deamon will automatically start with default settings. Adjust things (like the servers) to your likings