NTP: Unterschied zwischen den Versionen

Aus xinux.net
Zur Navigation springen Zur Suche springen
Zeile 135: Zeile 135:
 
  root@zero:~# ntpdate 192.168.242.1
 
  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
 
  7 Jul 09:57:54 ntpdate[1519]: step time server 192.168.242.1 offset -328.693068 sec
 +
 +
==Broadcast NTP-Server==
 +
Es besteht ebenfalls die Möglichkeit, den Server so zu konfigurieren, dass er die Zeit via Broadcast an ein ganzes
 +
Netz versendet. Dazu erweitert man
 +
* /etc/ntp.conf
 +
...
 +
# If you want to provide time to your local subnet, change the next line.
 +
# (Again, the address is an example only.)
 +
#broadcast 192.168.123.255
 +
broadcast 192.168.242.255
 +
 +
Auf dem Client muss entsprechend der Broadcast-Empfang aktiviert werden.
 +
...
 +
# 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
  
 
==Weitere Infos==
 
==Weitere Infos==

Version vom 28. Juli 2009, 13:52 Uhr

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
...

Festlegung des Driftfiles

 driftfile /var/lib/ntp/ntp.drift 

Im Driftfile wird die Abweichung der Systemuhr zur Referenzzeit (Offset) gespeichert. Diese Datei wird mit dem Starten des NTP Daemons gelesen und wird kontinuierlich angepasst.

Statistiken

Hiermit können (sehr technische) Statistiken über verschiedene Komponenten geführt werden.

Zum Aktivieren entfernt man das Kommentarzeichen vor statsdir

# Enable this if you want statistics to be logged.
statsdir /var/log/ntpstats/
statistics Statistikname
loopstats erlaubt Aufzeichnungen über den Loop Filter
peerstats erlaubt Aufzeichnunen über Peers
clockstats erlaubt Aufzeichnungen über die Systemuhr

Format für Loopstats

(Datum,Modifizierter Julianischer Tag) (Sekunden- und Bruchteile nach Mitternacht UTC) (Offset) (RMS Jitter) (Allan Abweichung)
root@zero:~# cat /var/log/ntpstats/loopstats
55035 40119.485 0.004551000 -6.379 0.001435093 0.064274 6

Format für peerstats

(Datum,Modifizierter Julianischer Tag) (Sekunden- und Bruchteile nach Mitternacht UTC) (Peer IP-Adresse) (Status) 
(Offset) (Delay) (Dispersion) (RMS Jitter)
root@zero:~# cat /var/log/ntpstats/peerstats
55035 40832.485 91.189.94.4 9614 0.005485220 0.039669868 0.001994688 0.001977256
Filegen Dateiname erstellt eine Datei für eine Statistik.
file Dateiname Dateiname, der für die Statistik benutzt werden soll
type Art der Datei, die genutzt werden soll. Day erstellt jeden Tag eine neue Datei

alternativ gibt es noch week, month und year

enable / disable erlaubt oder verbietet die Aufzeichnungsfunktion

Weitere Server

Weitere Server können mit

server servername

hinzugefügt werden.

server 0.de.pool.ntp.org        Serverpool ntp.org
server 1.de.pool.ntp.org
server 2.de.pool.ntp.org
server 3.de.pool.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] 

/etc/init.d/ntp muss dazu gestoppt sein. 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

Broadcast NTP-Server

Es besteht ebenfalls die Möglichkeit, den Server so zu konfigurieren, dass er die Zeit via Broadcast an ein ganzes Netz versendet. Dazu erweitert man

  • /etc/ntp.conf
...
# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255
broadcast 192.168.242.255

Auf dem Client muss entsprechend der Broadcast-Empfang aktiviert werden.

...
# 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

Weitere Infos

Im Paket

  • ntp-doc

sind weitere Informationen zu finden. Diese kann man über einen Webbrowser unter file:///usr/share/doc/ntp-doc/html/ntpd.html aufrufen.