Ntp

De Wiki Automatisme et Informatique.


Un serveur ntp peut vous servir pour synchroniser la date et l'heure de tous vos pc sur un réseau local (même si ceux ci ont un accès internet et peuvent se synchroniser sur les serveurs public)


Serveur NTP


on commence par installer les paquets ntp :

sudo apt-get install ntp

puis on modifie le fichier /etc/ntp.conf

# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help

driftfile /var/lib/ntp/ntp.drift 

# Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/

statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

listen on *

# You do need to talk to an NTP server or two (or three).
server ntp.ubuntu.com prefer
server ntp2.jussieu.fr
server ntp.uvsq.fr
server 0.fr.pool.ntp.org

# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details. The web page 
# might also be helpful.
#
# Note that « restrict » applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.

# By default, exchange time with everybody, but don’t allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery 

# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1 nomodify
# On permet aux machines du réseau 192.168.10.0/24 d’intérroger le serveur NTP
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict ::1

# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 192.168.123.0 mask 255.255.255.0 notrust 

# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.1.255

# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines. Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient

on relance le service :

/etc/init.d/ntp restart

on verifie que les synchros se font bien :

ntpq -np

et on doit avoir quelque chose de similaire à

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 91.189.94.4     193.79.237.14    2 u   51   64    7   63.483    3.605   5.933
 91.121.92.90    81.25.192.148    3 u   52   64    7  896.272  427.251 427.431
 162.23.41.34    .HBGi.           1 u   50   64    7   65.701    6.408   7.775
 145.238.203.10  145.238.203.14   2 u   50   64    7   55.844    9.035   7.915
 134.157.254.19  10.3.128.189     2 u   48   64    7   39.268   -0.215   5.986
 193.51.24.1     .INIT.          16 u    -   64    0    0.000    0.000   0.000
 129.175.34.43   145.238.203.14   2 u   48   64    7   41.078    3.294   5.110
 195.13.23.5     195.13.23.6      2 u   48   64    7   51.399    2.123  10.906

la valeur "reach" doit augmenter avec le temps (en partant de 1) et tant qu'elle n'est pas à 7, les clients ne peuvent pas se synchroniser sur ce serveur.


Récupérée de « http://wiki.saiia.fr/index.php/Ntp »