====== Installer et tester NTP ======
Sources:
* [[https://doc.ubuntu-fr.org/ntp]]
Apparement sous la version Ubuntu server 18.04 la synchronisation se fait d'office
"Sous les dernières versions d’Ubuntu, l’horloge système est automatiquement synchronisée en réseau. Cette synchronisation est gérée par le service systemD systemd-timesyncd.service . Vous pouvez accéder à plus d’informations sur ce service par la commande :
$ systemctl status systemd-timesyncd
Source: [[https://openclassrooms.com/fr/courses/1733551-gerez-votre-serveur-linux-et-ses-services/5236031-configurez-un-serveur-de-temps-pour-etre-toujours-a-l-heure]]
===== Installation =====
Installation du client NTP et NTPSTAT :
sudo apt-get install ntp ntpstat
===== Service NTP =====
voir le status avec ''service ntp status''
thierry@bino:~$ sudo service ntp status
● ntp.service - Network Time Service
Loaded: loaded (/lib/systemd/system/ntp.service; enabled; vendor preset: enab
Active: active (running) since Fri 2018-10-26 10:44:31 UTC; 2s ago
Docs: man:ntpd(8)
Process: 1316 ExecStart=/usr/lib/ntp/ntp-systemd-wrapper (code=exited, status=
Main PID: 1332 (ntpd)
Tasks: 2 (limit: 2320)
CGroup: /system.slice/ntp.service
└─1332 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 111:113
oct. 26 10:44:31 bino ntpd[1332]: Listen and drop on 1 v4wildcard 0.0.0.0:123
oct. 26 10:44:31 bino ntpd[1332]: Listen normally on 2 lo 127.0.0.1:123
oct. 26 10:44:31 bino ntpd[1332]: Listen normally on 3 ens18 192.168.1.104:123
oct. 26 10:44:31 bino ntpd[1332]: Listen normally on 4 lo [::1]:123
oct. 26 10:44:31 bino ntpd[1332]: Listen normally on 5 ens18 [fd00::1:fc63:4cff:
oct. 26 10:44:31 bino ntpd[1332]: Listen normally on 6 ens18 [fe80::fc63:4cff:fe
oct. 26 10:44:31 bino ntpd[1332]: Listening on routing socket on fd #23 for inte
oct. 26 10:44:32 bino ntpd[1332]: Soliciting pool server 91.121.157.10
oct. 26 10:44:33 bino ntpd[1332]: Soliciting pool server 129.250.35.251
oct. 26 10:44:33 bino ntpd[1332]: Soliciting pool server 62.4.3.34
===== Vérifications =====
==== Avec NTP (ntpq -p) ====
thierry@binova:~$ ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
0.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.008
1.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.008
2.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.008
3.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.008
ntp.ubuntu.com .POOL. 16 p - 64 0 0.000 0.000 0.008
#148.ip-193-70-9 78.47.94.77 3 u 55 64 77 30.002 -1.199 3.900
+ntp.univ-angers 145.238.203.14 2 u 52 64 77 48.469 -0.517 3.088
+y.ns.gin.ntt.ne 249.224.99.213 2 u 51 64 77 25.693 0.064 2.477
+ntp4.rbx-fr.hos 131.188.3.220 2 u 45 64 77 27.502 -0.856 4.238
+web01.webhd.nl 149.202.97.123 3 u 47 64 77 30.488 0.327 1.366
+dedibox.demonge 145.238.203.14 2 u 45 64 77 26.051 0.564 1.385
+merlin.deuza.ne 145.238.203.14 2 u 45 64 77 24.948 -0.273 2.288
#ns1.pulsation.f 178.32.220.7 3 u 47 64 77 32.589 17.732 2.629
#ns2.pulsation.f 145.238.203.14 2 u 50 64 77 29.581 87.496 3.362
+163-172-10-212. 79.143.250.152 2 u 44 64 77 24.742 -1.080 0.753
+ntp.tuxfamily.n 145.238.203.14 2 u 47 64 77 37.575 0.101 0.769
+ns1.hezzel.org 213.251.128.249 2 u 48 64 77 29.502 -0.372 1.191
+ns.rail.eu.org 124.216.164.14 2 u 48 64 77 24.794 0.077 0.811
#chilipepper.can 17.253.34.253 2 u 59 64 77 34.133 -1.589 1.430
*ns300973.ip-91- 145.238.203.14 2 u 41 64 77 27.238 -0.664 0.972
#pugot.canonical 17.253.52.253 2 u 51 64 77 35.582 -1.697 1.168
==== Avec NTPSTAT (ntpstat) ====
thierry@binova:~$ ntpstat
synchronised to NTP server (195.154.174.209) at stratum 3
time correct to within 17 ms
polling server every 64 s
===== Commandes =====
====> ntpdate====
=== Forcer une mise a jour de la date ===
On verifie la date avec la commande ''date'' :
> date
Tue Feb 16 17:09:21 CET 2021
On constate avec consternation que ce n'est la bonne date.\\
On veut la synchroniser avec le serveur ''2.fr.pool.ntp.org'' (pris au hasard)
# On arrete le service ntpd
> service ntpd stop
Redirecting to /bin/systemctl stop ntpd.service
# On lance la commande de mise a jour sur le serveur 2.fr.pool.ntp.org
> ntpdate 2.fr.pool.ntp.org
17 Feb 10:38:38 ntpdate[13731]: step time server 82.66.249.102 offset 62456.701528 sec
# On verifie
> date
Wed Feb 17 10:38:42 CET 2021
# C'est OK on relance le service ntpd
> service ntpd start
Redirecting to /bin/systemctl start ntpd.service
===== Voir aussi =====
* [[linux:commandes:datetimes|Commandes Linux sur les Dates et Heures]]