Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
| software:syslog-ng [2008/10/22 17:52] – st | software:syslog-ng [2018/07/23 12:29] (aktuell) – [verschlüssel mit stunnel] st | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| + | ====== Syslog-ng ====== | ||
| + | [[wpde> | ||
| + | |||
| + | Im Gegensatz zum alten syslog bietet syslog-ng mehr Funktionen (z. B. tcp-Verbindungen) und ist flexibler zu konfigurieren. Es existiert auch eine [[http:// | ||
| + | |||
| + | ===== Links ===== | ||
| + | |||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | |||
| + | ===== Konfiguration ===== | ||
| + | |||
| + | Die Konfiguration von syslog-ng ist relativ gut in der Datei ''/ | ||
| + | |||
| + | Die allgemeine Syntax ist nach dem Schema | ||
| + | |||
| + | < | ||
| + | NAME { | ||
| + | # Kommentare | ||
| + | EINSTELLUNG(PARAMETER); | ||
| + | }; | ||
| + | </ | ||
| + | Jede Zeile und jeder Block (geschweifte Klammerm) wird also mit einem Semikolon abgeschlossen | ||
| + | |||
| + | Grundsätzlich sind vier Arten von Einstellungen zu machen | ||
| + | - Optionen (options | ||
| + | - Quellen (source) | ||
| + | - Filter (filter) | ||
| + | - Ziele (destination) | ||
| + | |||
| + | ==== Optionen (options) ==== | ||
| + | Optionen (options) wirken global. | ||
| + | |||
| + | < | ||
| + | options { | ||
| + | # the number of lines buffered before written to file | ||
| + | # you might want to increase this if your disk isn't catching with | ||
| + | # all the log messages you get or if you want less disk activity | ||
| + | # (say on a laptop) | ||
| + | # (default is 0) | ||
| + | #sync(0); | ||
| + | }; | ||
| + | </ | ||
| + | |||
| + | ==== Quellen (source) ==== | ||
| + | Quellen (source): Hier wird die Quellen von Protokolldaten angegeben. | ||
| + | |||
| + | Allgemeine Syntax: | ||
| + | < | ||
| + | source NAME { | ||
| + | | ||
| + | }; | ||
| + | </ | ||
| + | |||
| + | Als Quellen werden | ||
| + | - **Pipes** < | ||
| + | - **Dateien** (files) < | ||
| + | - **Netzwerkquellen** über | ||
| + | - UDP < | ||
| + | - TCP unterstützt.< | ||
| + | source NAME {tcp(ip(" | ||
| + | | ||
| + | }; | ||
| + | </ | ||
| + | |||
| + | Letzteres wird bei einer Konfiguration als Log-Host (siehe unten) wichtig. | ||
| + | |||
| + | |||
| + | Die vorgegebene Quelle s_all sieht so aus: | ||
| + | < | ||
| + | source s_all { | ||
| + | # message generated by Syslog-NG | ||
| + | internal(); | ||
| + | # standard Linux log source (this is the default place for the syslog() | ||
| + | # function to send logs to) | ||
| + | unix-stream("/ | ||
| + | # messages from the kernel | ||
| + | file("/ | ||
| + | # use the following line if you want to receive remote UDP logging messages | ||
| + | # (this is equivalent to the " | ||
| + | # udp(); | ||
| + | }; | ||
| + | </ | ||
| + | |||
| + | ==== Filter (filter) ==== | ||
| + | * facility(facility1, | ||
| + | * level(prio1, | ||
| + | * program(regexp): | ||
| + | * host(regexp): | ||
| + | * match(regexp): | ||
| + | * filter(filter_name): | ||
| + | |||
| + | [[http:// | ||
| + | |||
| + | |||
| + | ==== Ziele (destination) ==== | ||
| + | Ziele (destinations): | ||
| + | |||
| + | < | ||
| + | destination d_syslog { file("/ | ||
| + | </ | ||
| + | Anstatt Dateien können auch andere Ziele (z. B. über tcp) angegeben werden: | ||
| + | < | ||
| + | destination loghost {tcp(" | ||
| + | </ | ||
| + | |||
| + | Als Ziel ist auch eine [[datenbanken: | ||
| + | |||
| + | :!: Es gibt die Möglichkeit ein Ausgabeformat mit template() festzulegen. Dies und mehr wird in der **[[http:// | ||
| + | |||
| + | Auf einem Loghost eine eine Sortierung nach Hosts usw. sehr nützlich. Beispiel: | ||
| + | < | ||
| + | destination std { | ||
| + | file("/ | ||
| + | owner(root) group(root) perm(0600) dir_perm(0700) create_dirs(yes) | ||
| + | ); | ||
| + | }; | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== minimales Beispiel ==== | ||
| + | |||
| + | Ein minimales Beispiel für die facility local0: | ||
| + | < | ||
| + | destination df_local0 { file("/ | ||
| + | filter f_local0 { facility(local0); | ||
| + | log { | ||
| + | source(s_all); | ||
| + | filter(f_local0); | ||
| + | destination(df_local0); | ||
| + | }; | ||
| + | </ | ||
| + | |||
| + | ===== LogHost mit syslog-ng ===== | ||
| + | |||
| + | ==== unverschlüsselt ==== | ||
| + | |||
| + | - '' | ||
| + | - **auf dem Client** in der Datei ''/ | ||
| + | destination loghost {tcp(" | ||
| + | |||
| + | log { | ||
| + | source(s_all); | ||
| + | destination(loghost); | ||
| + | }; | ||
| + | </ | ||
| + | - **auf dem Server** in der Datei ''/ | ||
| + | source s_remote { | ||
| + | tcp(ip(" | ||
| + | port(30514) | ||
| + | max-connections(1)); | ||
| + | }; | ||
| + | |||
| + | destination d_remote_syslogs { | ||
| + | file("/ | ||
| + | }; | ||
| + | |||
| + | # syslog von den Clients | ||
| + | log { | ||
| + | | ||
| + | | ||
| + | | ||
| + | }; | ||
| + | |||
| + | # auth, | ||
| + | |||
| + | destination d_remote_auths { | ||
| + | file("/ | ||
| + | }; | ||
| + | |||
| + | log { | ||
| + | | ||
| + | | ||
| + | | ||
| + | }; | ||
| + | </ | ||
| + | options { | ||
| + | long_hostnames(off); | ||
| + | sync(0); # Anzahl der Zeilen bevor auf die Festplatte geschrieben wird | ||
| + | keep_hostname(yes); | ||
| + | chain_hostnames(no); | ||
| + | }; | ||
| + | </ | ||
| + | # all messages from the auth and authpriv facilities | ||
| + | filter f_auth { facility(auth, | ||
| + | |||
| + | # all messages except from the auth and authpriv facilities | ||
| + | filter f_syslog { not facility(auth, | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | ==== verschlüssel mit stunnel ==== | ||
| + | |||
| + | FIXME unfertig. | ||
| + | Allgemeine Konfigurationsbeispiele siehe Seite von [[software: | ||
| + | |||
| + | - '' | ||
| + | - Zertfikate Server und alle Clients erzeugen (Dateinamen anpassen!): | ||
| + | - < | ||
| + | - < | ||
| + | - Die Zertifikate der Clients in einer einzelnen Datei sammeln und abspeichern: | ||
| + | nano all-clients.pem </ | ||
| + | - nach ''/ | ||
| + | - die Client-Zertifikate auf die entsprechenden Rechner verteilen | ||
| + | - stunnel auf dem Server und auf dem Client konfigurieren: | ||
| + | - Server: | ||
| + | - Client: | ||
| + | - Konfiguration von Syslog-ng: | ||
| + | - Server: Am Ende der Konfigurationsdatei ''/ | ||
| + | destination loghost {tcp(" | ||
| + | # destination stunnel {tcp(" | ||
| + | # | ||
| + | # log {source(src); | ||
| + | # | ||
| + | # *.*; | ||
| + | log { | ||
| + | source(s_all); | ||
| + | # filter(f_syslog); | ||
| + | destination(loghost); | ||
| + | }; | ||
| + | |||
| + | </ | ||
| + | - Client:< | ||
| + | options { long_hostnames(off); | ||
| + | | ||
| + | source src {unix-stream("/ | ||
| + | | ||
| + | | ||
| + | destination dest {file("/ | ||
| + | destination stunnel {tcp(" | ||
| + | |||
| + | log {source(src); | ||
| + | log {source(src); | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Fehlerbehandlung ===== | ||
| + | |||
| + | Wenn man an der Konfigurations schraubt muss man aufpassen, dass nach Konfigurationsfehlern am Ende auch syslog-ng wieder läuft. Ein normales < | ||
| + | |||
| + | Einen Patch dafür und wie man ihn anwendet hab ich [[linux: | ||
| + | |||