TechEvent 2019: The sleeping Power of Data; Eberhard Lösch - Trivadis
Rsyslog - Deutsche Qualitätsarbeit für Linux
1. BASEL BERN BRUGG DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. GENF
HAMBURG KOPENHAGEN LAUSANNE MÜNCHEN STUTTGART WIEN ZÜRICH
Rsyslog – deutsche Qualitätsarbeit für Linux
DOAG Jahrestagung 18. November 2015
Roman Gächter
4. Agenda
Rsyslog – deutsche Qulitästarbeit für Linux
4
14/
11/
15
1. Konzept der Syslog Implementierung
2. Rsyslog
Übersicht
Features
3. Konfiguration
Server
Client
4. Auditd
5. Betrieb
Upgrades
Administration
Fehlersuche
6. Fazit
6. Syslog Konzept
Rsyslog – deutsche Qulitästarbeit für Linux6 14/11/15
Zentrale Ablage von Syslogs
Syslog Server
– Zwei redundante Server
Verwenden von Rsyslog
– Neuer Standard für RHEL basierte Distributionen
– Enterprise Erweiterungen in Rsyslog
• high-performance“
• „great security features“
• Verschlüsselte Übertragung mit TLS
• „modular design“
7. Syslog Konzept
Rsyslog – deutsche Qulitästarbeit für Linux7 14/11/15
Zentrale Ablage von Syslogs
Sammeln Security relevanter Logs
Korrelieren und trennen nach
– „priorities“
– „facilities“
Audit Watches
– Alarmierung durch Rsyslog
Filter Rules
– Proaktive Reaktion auf Fehler
11. Rsyslog Übersicht
Rsyslog – deutsche Qulitästarbeit für Linux11 14/11/15
Dank an Rainer Gerhards
Deutsche Qualitätsarbeit setzt sich durch
Heute Standard bei Linux Distributionen
– Redhat basierte
– Debian basierte
– SuSE basierte
12. Rsyslog Übersicht
Rsyslog – deutsche Qulitästarbeit für Linux12 14/11/15
RFC‘s zu Syslog
RFC 3164
– The BSD syslog Protocol (obsoleted by RFC 5424)
RFC 5424
– The Syslog Protocol (obsoletes RFC 3164)
– https://tools.ietf.org/html/rfc5424
RFC 5425
– Transport Layer Security Mapping for Syslog
RFC 5426
– Transmission of Syslog Messages over UDP
13. Rsyslog Übersicht
Rsyslog – deutsche Qulitästarbeit für Linux13 14/11/15
„Facility Keywords“ für facility-basierte Filter
Ebene 1
14. Rsyslog Übersicht
Rsyslog – deutsche Qulitästarbeit für Linux14 14/11/15
Beispiel Zuordnung der „kernel“ Facility
# Log all local kernel messages to the console
# and /var/log/kern
if $hostname == ‘syslogsrv1'
and $syslogfacility == '0'
then /var/log/kern
15. Rsyslog Übersicht
Rsyslog – deutsche Qulitästarbeit für Linux15 14/11/15
Facility values MUST be in the range of 0 to 23 inclusive
16. Rsyslog Übersicht
Rsyslog – deutsche Qulitästarbeit für Linux16 14/11/15
„Priority Keywords“ für priority-basierte Filter
17. Rsyslog Übersicht
Rsyslog – deutsche Qulitästarbeit für Linux17 14/11/15
Beispiel Zuordnung der „error“ priority
if $syslogseverity == '3'
then /u00/rsyslog/priority/error
19. Rsyslog Übersicht
Rsyslog – deutsche Qulitästarbeit für Linux19 14/11/15
Features
Homepage
– „RSYSLOG is the rocket-fast system for log processing“
– „It offers high-performance, great security features and a modular design“
„Multi-threading“
TCP, SSL, TLS, RELP
MySQL, PostgreSQL, Oracle und mehr
Filterung der Syslog Message
„Fully configurable output format“
„Suitable for enterprise-class relay chains“
20. Rsyslog Features
Rsyslog – deutsche Qulitästarbeit für Linux20 14/11/15
Struktur
Input Modules
– $ModLoad imuxsock
• provides support for local system logging
– $ModLoad imklog
• provides kernel logging support (previously done by rklogd)
Rulesets
– Filtering
21. Rsyslog Features
Rsyslog – deutsche Qulitästarbeit für Linux21 14/11/15
Struktur
Actions
– Schreiben in Files
– DB Backends
– Weiterleiten
22. Rsyslog Features
Rsyslog – deutsche Qulitästarbeit für Linux22 14/11/15
Modules, functionality to be dynamically loaded from modules
$ModLoad MODULE_name
Filter modules
Library modules
Input modules
Output modules
Message modification modules
Parser modules
String generator modules
Template features
23. Rsyslog Features
Rsyslog – deutsche Qulitästarbeit für Linux23 14/11/15
RELP
„Relaible Event Logging Protocol“
TLS Session Abbruch
RELP und TLS
– Mit 7.4.7 (2013-12-10) noch nicht unterstützt, erst ab 7.5.1
Jan 13 11:08:38 srv105 rsyslogd-2078: netstream session 0x4988510 will be closed
due to error
24. Konfiguration
Rsyslog – deutsche Qulitästarbeit für Linux24 14/11/15
Struktur und Konfigurations Management Tools
Aufteilen der Konfiguration
– Basis Konfig im/etc/rsyslog.conf
• Includes im /etc/rsyslog.d
> /etc/rsyslog.conf/server.conf
> /etc/rsyslog/client.conf
Konfigurations Management Tools
– Puppet
• saz-rsyslog Module
25. Konfiguration
Rsyslog – deutsche Qulitästarbeit für Linux25 14/11/15
Standard Syslog Syntax
Kann man verwenden
# Everybody gets emergency messages
*.emerg *
*.info /u00/rsyslog/hosts/all/messages
27. Konfiguration
Rsyslog – deutsche Qulitästarbeit für Linux27 14/11/15
TLS Verschlüsselung
Certificate Files
Authentifizierung
$DefaultNetstreamDriverCAFile /rsyslog/protected/CA_bundle.pem
$DefaultNetstreamDriverCertFile /rsyslog/protected/server_cert.myhostname.pem
$DefaultNetstreamDriverKeyFile /rsyslog/protected/server_private_myhostname.key
$ActionSendStreamDriverAuthMode x509/name
$ActionSendStreamDriverPermittedPeer syslog-server1.mydomain
$ActionSendStreamDriverPermittedPeer syslog-server2.mydomain
$ActionSendStreamDriverMode 1 # run driver in TLS-only mode
28. Konfiguration
Rsyslog – deutsche Qulitästarbeit für Linux28 14/11/15
TLS Verschlüsselung
X509 Zertifikate
– Ab Oracle Linux 6
• min. 2048 Bit Zertifikate
– Rsyslog Problem mit SHA2
29. Konfiguration
Rsyslog – deutsche Qulitästarbeit für Linux29 14/11/15
Filter
Neues „style format“
– Rainer Script
if $msg contains 'Abort command issued'
or $msg contains 'blocked for more than 120 seconds'
or $msg contains 'checker reports path is down'
or $msg contains 'kernel: device-mapper: multipath: Failing path'
or $msg contains 'multipathd: checker failed path'
or $msg contains ': mark as failed'
or $msg contains 'checker reports path is up'
or $msg contains 'require eh work'
or $msg contains 'Error handler scsi_eh'
or $msg contains 'FCP command status'
or $msg contains 'aborting sp'
or $msg contains 'firmware reported underrun'
or $msg contains 'Dropped frame(s) detected'
or $msg contains 'kernel: end_request: I/O error'
or $msg contains 'error calling out /sbin/mpath_prio_alua'
then /u00/rsyslog/applications/scripts/scsiaborts
30. Konfiguration
Rsyslog – deutsche Qulitästarbeit für Linux30 14/11/15
Templates
Beispiel
$template HostAudit, "/u00/rsyslog/applications/auditd/%HOSTNAME%/audit_log"
$template auditFormat, "%msg%n"
local5.* ?HostAudit;auditFormat
31. Konfiguration
Rsyslog – deutsche Qulitästarbeit für Linux31 14/11/15
Rules
„forwarding rules“
# forward everything to remote servers
*.* @@fqdn-syslogserver1:10514
*.* @@fqdn-syslogserver2:10514
33. Konfiguration
Rsyslog – deutsche Qulitästarbeit für Linux33 14/11/15
Regex
POSIX ERE oder BRE
Online Regex Checker
– http://www.rsyslog.com/regex/
:msg, regex, "sshd.* session opened for user q[a-z0-9]*[0-9]”
/lfs/oracle_audit/os.log
35. Auditd
Rsyslog – deutsche Qulitästarbeit für Linux35 14/11/15
Auditd
Zentrale Ablage der Audit Logs
– Korrelation von Sicherheitsvorfällen
– Zentrale Auswertung mit Audit Tools
Audit Watches
– Reaktion auf „audit watch“ Triggers mit Rsyslog
36. Auditd
Rsyslog – deutsche Qulitästarbeit für Linux36 14/11/15
Konfiguration
Imfile Module
Beispiel local5
$ModLoad imfile
$InputFileName /var/log/audit/audit.log
$InputFileTag tag_audit_log:
$InputFileStateFile audit_log
$InputFileSeverity info
$InputFileFacility local5
$InputRunFileMonitor
37. Auditd
Rsyslog – deutsche Qulitästarbeit für Linux37 14/11/15
Konfiguration
Format beibehalten
Auswerten
– ausearch
– aureport
$template HostAudit, “/u00/rsyslog/auditd/%HOSTNAME%/audit_log"
$template auditFormat, "%msg%n" local5.* ?HostAudit;auditFormat
38. Auditd
Rsyslog – deutsche Qulitästarbeit für Linux38 14/11/15
Konfiguration
Keine Audit Logs im „messages“ des Syslogservers
if $hostname == ‘syslogsrv1'
and not ( $syslogfacility == '2' )
and not ( $syslogfacility == ‘21' )
and not ( $syslogfacility-text == 'cron' )
and not ( $syslogtag == 'tag_audit_log:' )
then /var/log/messages
39. Auditd
Rsyslog – deutsche Qulitästarbeit für Linux39 14/11/15
Änderungen von Files in Realtime erkennen
Beispiel Audit Rule
– /etc/audit/audit.rules
– Dynamisch aktivieren
-w /etc/sd_pam.conf -p w -k sd_pam.conf_changed
auditctl -R /etc/audit/audit.rules
40. Auditd
Rsyslog – deutsche Qulitästarbeit für Linux40 14/11/15
Änderungen von Files in Realtime erkennen
In Rsyslog Konfig
$template FileWatcher, "%HOSTNAME% %msg%n"
if $msg contains 'sd_pam.conf_changed'
and $msg contains 'type=SYSCALL'
then ^/usr/local/bin/generic_audit_filewatcher_alerter.ksh;FileWatcher
42. Betrieb
Rsyslog – deutsche Qulitästarbeit für Linux42 14/11/15
Upgrade auf Oracle Linux 7.1
Gibt Warnung aus
Mit omruleset definieren
Kernel Logging
*.emerg :omusrmsg:*
*.emerg *
#$ModLoad imklog # provides kernel logging support
$ModLoad imjournal # provides access to the systemd journal
43. Betrieb
Rsyslog – deutsche Qulitästarbeit für Linux43 14/11/15
Upgrade auf Oracle Linux 7.1
Probleme mit X509 Zertifikaten
– SSL-Lib akzeptiert nur noch 2048 Bit Keys
– 2048 Bit mit MD5 signiert ??
– 2048 Bit mit SHA2 signiert ??
– 2048 Bit mit SHA1
44. Betrieb
Rsyslog – deutsche Qulitästarbeit für Linux44 14/11/15
Upgrade auf Oracle Linux 7.1
PID Filename geändert
Logrotate
/var/run/syslogd.pid
/var/run/rsyslogd.pid
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null`
45. Betrieb
Rsyslog – deutsche Qulitästarbeit für Linux45 14/11/15
Housekeeping
Logrotate
– /etc/logrotate.d/syslog
– Logrotate Debugging
Fehlersuche
– Syntaxchecker
– Debugging
rsyslogd -N 1
46. Betrieb
Rsyslog – deutsche Qulitästarbeit für Linux46 14/11/15
Fehlersuche
Debugging
export RSYSLOG_DEBUGLOG="/path/to/debuglog"
export RSYSLOG_DEBUG="Debug“
rsyslogd -dn