Configuring the NTP Service - dcasota/photonos-scripts GitHub Wiki

Here a code snippet on how to install and configure the ntp service (using local root privileges).

tdnf install -y ntp

Add server entries (Here in Switzerland eg. server ntp11.metas.ch, ntp12.metas.ch, ntp13.metas.ch) vi /etc/ntp.conf

tinker panic 0
restrict default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
driftfile /var/lib/ntp/drift/ntp.drift

server <your time server 1>
server <your time server 2>
server <your time server 3>

Configure iptables, enable and start ntp daemon. Hint: After a Photon OS upgrade this step has to be enforced again.

iptables -A INPUT -i eth0 -p udp --dport 123 -j ACCEPT
iptables-save >/etc/systemd/scripts/ip4save
ip6tables-save >/etc/systemd/scripts/ip6save
systemctl enable ntpd
systemctl start ntpd

Print peer list.

ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 ntp11.metas.ch  .MRS.            1 u   41   64    1    3.487   +4.763   0.000
 ntp12.metas.ch  .MRS.            1 u   45   64    1    3.521   +4.729   0.000
 ntp13.metas.ch  .MRS.            1 u   42   64    1    3.791   +4.695   0.000

It is also necessary to configure the timezone.

set Europe/Zurich timezone
ln -sf /usr/share/zoneinfo/Europe/Zurich /etc/localtime

Sync now, and sync the RTC clock to system clock:

systemctl stop ntpd
ntpdate -s <your ntp server>
systemctl start ntpd
hwclock --systohc --localtime