Ntp: Difference between revisions

From wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 35: Line 35:
;timedatectl timesync-status
;timedatectl timesync-status
:Detailed status of systemd-timesyncd
:Detailed status of systemd-timesyncd
If you want to use ntp instead of timesyncd e.g. because you want to run a ntp server use:
<syntaxhighlight lang=bash>
systemctl disable systemd-timesyncd.service
apt install ntp
</syntaxhighlight>
The NTP deamon will automatically start with default settings. Adjust things (like the servers) to your likings

Revision as of 15:27, 26 July 2024

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

timedatectl timesync-status
Detailed status of systemd-timesyncd

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