Debian Buster NTP

Bonjour,

je suis en train d’installer un prototype de Debian Buster durcie avec 4 interfaces pour remplacer mon OPNsense qui ne me convient pas.
Dans les diverses focntionnalités que j’y implémente, après le dhcp, le dhcpv6, le bind, je me suis atelé à NTP.

l’idée c’est d’utiliser NTP pour mettre à jour les machines des sous réseaux (sur deux des interfaces uniquement) avec:

  • le prototype met à jour son horloge sur des serveurs (debian.pool.ntp.org par exemple)
  • il écoute sur les deux interfaces des deux sous reseaux voulus en ipv4 et ipv6

cependant, j’ai un problème de taille, le NTP ne synchronise pas, et les client derrière détectant un stratum de 16 ne mettent pas à jour non plus.

j’ai désactivé timesyncd. Le status me donne:

root@d10faustsrv:~# timedatectl status
               Local time: jeu. 2020-10-22 17:29:01 CEST
           Universal time: jeu. 2020-10-22 15:29:01 UTC
                 RTC time: jeu. 2020-10-22 15:27:02
                Time zone: Europe/Paris (CEST, +0200)
System clock synchronized: no
              NTP service: inactive
          RTC in local TZ: no

ce qui montre que NTP n’est pas détecté. Concenrant NTP j’ai une erreur que je n’arrive pas à corriger:

Oct 22 16:35:59 d10faustsrv systemd[1]: ntp.service: Succeeded.
Oct 22 17:29:56 d10faustsrv ntpd[2517]: ntpd 4.2.8p12@1.3728-o (1): Starting
Oct 22 17:29:56 d10faustsrv ntpd[2517]: Command line: /usr/sbin/ntpd -p /var/run/ntpd.pid -g -c /run/ntp.conf.dhcp -u 106:113
Oct 22 17:29:56 d10faustsrv ntpd[2523]: proto: precision = 0.050 usec (-24)
Oct 22 17:29:56 d10faustsrv ntpd[2523]: Listen and drop on 0 v6wildcard [::]:123
Oct 22 17:29:56 d10faustsrv ntpd[2523]: Listen and drop on 1 v4wildcard 0.0.0.0:123
Oct 22 17:29:56 d10faustsrv ntpd[2523]: Listen normally on 2 lo 127.0.0.1:123
Oct 22 17:29:56 d10faustsrv ntpd[2523]: Listen normally on 3 enp0s8 *******:123
Oct 22 17:29:56 d10faustsrv ntpd[2523]: Listen normally on 4 enp0s9 *******:123
Oct 22 17:29:56 d10faustsrv ntpd[2523]: Listen normally on 5 lo [::1]:123
Oct 22 17:29:56 d10faustsrv ntpd[2523]: Listen normally on 6 enp0s8 [fec0:12b:ff55:1921:6810::254]:123
Oct 22 17:29:56 d10faustsrv ntpd[2523]: Listen normally on 7 enp0s8 [*******]:123
Oct 22 17:29:56 d10faustsrv ntpd[2523]: Listen normally on 8 enp0s9 [*******]:123
Oct 22 17:29:56 d10faustsrv ntpd[2523]: Listen normally on 9 enp0s9 [*******]:123
Oct 22 17:29:56 d10faustsrv ntpd[2523]: Listening on routing socket on fd #26 for interface updates
Oct 22 17:29:56 d10faustsrv ntpd[2523]: kernel reports TIME_ERROR: 0x4041: Clock Unsynchronized
Oct 22 17:29:56 d10faustsrv ntpd[2523]: 0.0.0.0 c01d 0d kern kernel time sync enabled
Oct 22 17:29:56 d10faustsrv ntpd[2523]: **kernel reports TIME_ERROR: 0x4041: Clock Unsynchronized**
Oct 22 17:29:56 d10faustsrv ntpd[2523]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM
Oct 22 17:29:56 d10faustsrv ntpd[2523]: 0.0.0.0 c016 06 restart
Oct 22 17:30:03 d10faustsrv ntpd[2523]: 0.0.0.0 c615 05 clock_sync

Où l’on voit bien le problème d’erreur lié au ait du timesyncd en conflit bien que desactivé.

Le /etc/ntp.conf est le suivant:

#
# Autogenerated configuration file
#

#tinker panic 0
# Orphan mode stratum
#tos orphan 12


# Upstream Servers
server 0.debian.pool.ntp.org iburst maxpoll 9 prefer
server 1.debian.pool.ntp.org iburst maxpoll 9
server 2.debian.pool.ntp.org iburst maxpoll 9
server 3.debian.pool.ntp.org iburst maxpoll 9


#disable monitor
enable stats
statistics clockstats loopstats peerstats
statsdir /var/log/ntpstats
logconfig =syncall +clockall +sysall
driftfile /var/lib/ntp/ntp.drift
restrict default kod limited nomodify nopeer notrap
restrict -6 default kod limited nomodify nopeer notrap

interface ignore all
interface listen enp0s8
interface listen enp0s9

restrict 127.0.0.1
restrict ::1

le timesyncd pour faire bonne mesure:

root@d10faustsrv:~# systemctl status systemd-timesyncd.service
● systemd-timesyncd.service - Network Time Synchronization
   Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
  Drop-In: /usr/lib/systemd/system/systemd-timesyncd.service.d
           └─disable-with-time-daemon.conf
   Active: inactive (dead)
Condition: start condition failed at Thu 2020-10-22 16:35:59 CEST; 56min ago
           └─ ConditionFileIsExecutable=!/usr/sbin/VBoxService was not met
     Docs: man:systemd-timesyncd.service(8)

oct. 22 16:32:07 d10faustsrv systemd[1]: Condition check resulted in Network Time Synchronization being skipped.
oct. 22 16:34:57 d10faustsrv systemd[1]: Condition check resulted in Network Time Synchronization being skipped.
oct. 22 16:35:59 d10faustsrv systemd[1]: Condition check resulted in Network Time Synchronization being skipped.

Après plus d’une heure de tests, je pense que je dois passer à coté de quelque chose.

Pour un usage identique en Debian Buster, me suis contenté d’installer puis de configurer le package chrony et n’ai pas recontré de problème particulier. N’ai pas eu besoin de désactiver systemd-timesyncd .

timedatectl indique également que le service NTP est inactif. Etant relativement allergique à tout ce qui est systemd, je n’y apporte pas vraiment d’importance.

Pour indiquer aux clients DHCP quel serveur NTP utiliser, est-ce que tu leur fournis bien l’option DHCP 42 « ntp-servers » ?


AnonymousCoward

ça se synchronise facilement avec systemd

Salut,

Il est inutile de désactiver le service systemd-timesyncd puisque celui-ci n’est pas lancé si ntpd ou chrony est présent.
Le retour de timedatectl est a priori normal. J’ai la même chose sur un serveur de temps avec Chrony. La doc n’est pas très claire là dessus mais il semble que NTP service concerne le service systemd.

Pour le serveur ntpd il faut d’abord s’assurer que la machine est bien capable de résoudre les noms x. 0.debian.pool.ntp.org et que le décalage de l’horloge n’est pas trop important.

Il faudrait voir le retour de :

systemctl status ntpd

Pour forcer la synchronisation de l’horloge :

systemctl stop ntpd
ntpd -gq
systemctl start ntpd

@grandtoubab : @Zargos a besoin d’un serveur de temps pour son réseau. systemd-timesyncd ne peut pas faire cela, c’est uniquement un client NTP pas un serveur.

D’ailleurs après avoir mis à jour avec le systemd des backports, j’ai maintenant :

timedatectl
               Local time: ven. 2020-10-23 14:27:34 CEST
           Universal time: ven. 2020-10-23 12:27:34 UTC 
                 RTC time: ven. 2020-10-23 12:27:10     
                Time zone: Europe/Paris (CEST, +0200)   
System clock synchronized: yes                          
              NTP service: n/a                          
          RTC in local TZ: no  

et

timedatectl set-ntp on
Failed to set ntp: NTP not supported

Donc enfin un comportement cohérent de sytemd-timesyncd avec un serveur NTP installé (chrony). :wink:

systemctl status ntp
● ntp.service - Network Time Service
   Loaded: loaded (/lib/systemd/system/ntp.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-10-24 19:08:35 CEST; 1s ago
     Docs: man:ntpd(8)
  Process: 4061 ExecStart=/usr/lib/ntp/ntp-systemd-wrapper (code=exited, status=0/SUCCESS)
 Main PID: 4067 (ntpd)
    Tasks: 2 (limit: 4651)
   Memory: 1.7M
   CGroup: /system.slice/ntp.service
           └─4067 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 106:113

oct. 24 19:08:35 d10faustsrv ntpd[4067]: Listening on routing socket on fd #26 for interface updates
oct. 24 19:08:35 d10faustsrv ntpd[4067]: kernel reports TIME_ERROR: 0x2041: Clock Unsynchronized
oct. 24 19:08:35 d10faustsrv ntpd[4067]: 0.0.0.0 c01d 0d kern kernel time sync enabled
oct. 24 19:08:35 d10faustsrv ntpd[4067]: kernel reports TIME_ERROR: 0x2041: Clock Unsynchronized
oct. 24 19:08:35 d10faustsrv ntpd[4067]: 0.0.0.0 c012 02 freq_set kernel 12.274 PPM
oct. 24 19:08:35 d10faustsrv ntpd[4067]: 0.0.0.0 c016 06 restart
oct. 24 19:08:35 d10faustsrv ntpd[4067]: DNS 0.debian.pool.ntp.org -> 51.15.175.180
oct. 24 19:08:35 d10faustsrv ntpd[4067]: DNS 1.debian.pool.ntp.org -> 37.187.104.44
oct. 24 19:08:35 d10faustsrv ntpd[4067]: DNS 2.debian.pool.ntp.org -> 92.222.209.69
oct. 24 19:08:35 d10faustsrv ntpd[4067]: DNS 3.debian.pool.ntp.org -> 209.51.161.238


     service ntp status
    ● ntp.service - Network Time Service
       Loaded: loaded (/lib/systemd/system/ntp.service; enabled; vendor preset: enabled)
       Active: active (running) since Sat 2020-10-24 19:03:59 CEST; 5s ago
         Docs: man:ntpd(8)
      Process: 3926 ExecStart=/usr/lib/ntp/ntp-systemd-wrapper (code=exited, status=0/SUCCESS)
     Main PID: 3932 (ntpd)
        Tasks: 2 (limit: 4651)
       Memory: 1.5M
       CGroup: /system.slice/ntp.service
               └─3932 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 106:113

    oct. 24 19:03:59 d10faustsrv ntpd[3932]: Listening on routing socket on fd #26 for interface updates
    oct. 24 19:03:59 d10faustsrv ntpd[3932]: kernel reports TIME_ERROR: 0x2041: Clock Unsynchronized
    oct. 24 19:03:59 d10faustsrv ntpd[3932]: 0.0.0.0 c01d 0d kern kernel time sync enabled
    oct. 24 19:03:59 d10faustsrv ntpd[3932]: kernel reports TIME_ERROR: 0x2041: Clock Unsynchronized
    oct. 24 19:03:59 d10faustsrv ntpd[3932]: 0.0.0.0 c012 02 freq_set kernel 12.274 PPM
    oct. 24 19:03:59 d10faustsrv ntpd[3932]: 0.0.0.0 c016 06 restart
    oct. 24 19:03:59 d10faustsrv ntpd[3932]: DNS 0.debian.pool.ntp.org -> 51.255.197.148
    oct. 24 19:03:59 d10faustsrv ntpd[3932]: DNS 1.debian.pool.ntp.org -> 80.74.64.2
    oct. 24 19:03:59 d10faustsrv ntpd[3932]: DNS 2.debian.pool.ntp.org -> 151.80.124.104

Avec toujours l’erreur kernel reports TIME_ERROR: 0x2041: Clock Unsynchronized

Il y a là un problème car certain fichier ne sont accessible que par ntp:ntp mais ca donne:

24 Oct 19:06:04 ntpd[3979]: ntpd 4.2.8p12@1.3728-o (1): Starting
24 Oct 19:06:04 ntpd[3979]: Command line: ntpd -gq
24 Oct 19:06:04 ntpd[3979]: proto: precision = 0.076 usec (-24)
24 Oct 19:06:04 ntpd[3979]: Listen and drop on 0 v6wildcard [::]:123
24 Oct 19:06:04 ntpd[3979]: Listen and drop on 1 v4wildcard 0.0.0.0:123
24 Oct 19:06:04 ntpd[3979]: Listen normally on 2 lo 127.0.0.1:123
24 Oct 19:06:04 ntpd[3979]: Listen normally on 3 enp0s8 <ipv4>:123
24 Oct 19:06:04 ntpd[3979]: Listen normally on 4 enp0s9 <ipv4>:123
24 Oct 19:06:04 ntpd[3979]: Listen normally on 5 lo [::1]:123
24 Oct 19:06:04 ntpd[3979]: Listen normally on 6 enp0s8 [ipv6]:123
24 Oct 19:06:04 ntpd[3979]: Listen normally on 7 enp0s8 [ipv6]:123
24 Oct 19:06:04 ntpd[3979]: Listen normally on 8 enp0s9 [ipv6]:123
24 Oct 19:06:04 ntpd[3979]: Listen normally on 9 enp0s9 [ipv6]:123
24 Oct 19:06:04 ntpd[3979]: Listening on routing socket on fd #26 for interface updates
24 Oct 19:06:04 ntpd[3979]: 0.0.0.0 c016 06 restart
24 Oct 19:06:04 ntpd[3979]: DNS 0.debian.pool.ntp.org -> 37.187.104.44
24 Oct 19:06:04 ntpd[3979]: DNS 1.debian.pool.ntp.org -> 129.250.35.250
24 Oct 19:06:04 ntpd[3979]: DNS 2.debian.pool.ntp.org -> 37.59.63.125
24 Oct 19:06:04 ntpd[3979]: DNS 3.debian.pool.ntp.org -> 92.243.6.5
24 Oct 19:06:05 ntpd[3979]: couldn't unlink /var/log/ntpstats/peerstats: Permission denied
24 Oct 19:06:05 ntpd[3979]: can't open /var/log/ntpstats/peerstats.20201024: Permission denied
24 Oct 19:06:07 ntpd[3979]: couldn't unlink /var/log/ntpstats/peerstats: Permission denied
24 Oct 19:06:07 ntpd[3979]: can't open /var/log/ntpstats/peerstats.20201024: Permission denied
24 Oct 19:06:09 ntpd[3979]: couldn't unlink /var/log/ntpstats/peerstats: Permission denied
24 Oct 19:06:09 ntpd[3979]: can't open /var/log/ntpstats/peerstats.20201024: Permission denied
24 Oct 19:06:09 ntpd[3979]: couldn't unlink /var/log/ntpstats/peerstats: Permission denied
24 Oct 19:06:09 ntpd[3979]: can't open /var/log/ntpstats/peerstats.20201024: Permission denied
24 Oct 19:06:09 ntpd[3979]: couldn't unlink /var/log/ntpstats/peerstats: Permission denied
24 Oct 19:06:09 ntpd[3979]: can't open /var/log/ntpstats/peerstats.20201024: Permission denied
24 Oct 19:06:09 ntpd[3979]: couldn't unlink /var/log/ntpstats/peerstats: Permission denied
24 Oct 19:06:09 ntpd[3979]: can't open /var/log/ntpstats/peerstats.20201024: Permission denied
24 Oct 19:06:11 ntpd[3979]: couldn't unlink /var/log/ntpstats/peerstats: Permission denied
24 Oct 19:06:11 ntpd[3979]: can't open /var/log/ntpstats/peerstats.20201024: Permission denied
24 Oct 19:06:11 ntpd[3979]: couldn't unlink /var/log/ntpstats/peerstats: Permission denied
24 Oct 19:06:11 ntpd[3979]: can't open /var/log/ntpstats/peerstats.20201024: Permission denied
24 Oct 19:06:11 ntpd[3979]: ntpd: time slew -0.027836 s
ntpd: time slew -0.027836s
24 Oct 19:06:11 ntpd[3979]: couldn't unlink /var/log/ntpstats/loopstats: Permission denied
24 Oct 19:06:11 ntpd[3979]: can't open /var/log/ntpstats/loopstats.20201024: Permission denied

De fait pas de problème de résolution ni de gros décalage.

De ce que je vois le service ntp est bien lancé et fonctionne.
Je ne suis pas sûr que l’erreur indiquée soit bloquante, pour moi il s’agit d’un simple message d’avertissement.
Il faut vérifier avec mes commandes ntpq et ntpdate sur le serveur et sur les clients que cela fonctionne effectivement :

ntpq -pn
ntpdate -d serveur

La commande ntp gq doit être lancée en tant que root, après avoir arrêté le service ntp.