NTP
Das Network Time Protocol (NTP) ist ein Standard zur Synchronisierung von Uhren in Computersystemen über paketbasierte Kommunikationsnetze. NTP verwendet das verbindungslose Transportprotokoll UDP (Port 123).
Installation des Clients
root@zero:~# apt-get install ntp Paketlisten werden gelesen... Fertig Abhängigkeitsbaum wird aufgebaut Lese Status-Informationen ein... Fertig Vorgeschlagene Pakete: ntp-doc Die folgenden NEUEN Pakete werden installiert: ntp ...
Konfiguration
Nach der Installation ist keine weitere Konfiguration notwendig. Unter Ubuntu ist standardmäßig als NTP-Server ntp.ubuntu.com eingetragen. Die Konfigurationsdatei liegt unter /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 # You do need to talk to an NTP server or two (or three). server ntp.ubuntu.com ...
Weitere Server können hinzugefügt werden.
server pool.ntp.org Serverpool ntp.org server ptbtime1.ptb.de Physikalisch-Technische Bundesanstalt (Braunschweig) server ptbtime2.ptb.de Physikalisch-Technische Bundesanstalt, alternativer Server server time.windows.com Windows Zeitserver
Manuelle Synchronisation
ntpdate [NTP-Server]
Die Systemzeit kann manuell mit ntpdate synchronisiert werden. Wenn der NTP Daemon läuft sollte dies nicht erforderlich sein.
Beispiel
root@zero:~# ntpdate pool.ntp.org 6 Jul 14:53:12 ntpdate[8959]: adjust time server 78.46.73.8 offset -0.018683 sec
Lokaler NTP Server
Für ein LAN kann ein Unix-Rechner mit einem NTP Client die Zeit weitergeben, die er selbst von einem NTP Server bezogen hat. Dazu muss in /etc/ntp.conf der Zugriff für das entsprechende Netz erlaubt werden. Es dauert einige Zeit, bis der Server als "suitable" (dt. geeignet) gelistet wird.
/etc/ntp.conf
# You do need to talk to an NTP server or two (or three). server ntp.ubuntu.com ... # Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for # details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions> # 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 restrict 192.168.240.0 netmask 255.255.240.0 nomodify ...
Test
root@zero:~# ntpdate 192.168.242.1 7 Jul 09:57:54 ntpdate[1519]: step time server 192.168.242.1 offset -328.693068 sec