syslog-ng és az IPTABLES LOG..

Fórumok

Üdv.. Érdekes problémába futottam, amire jó idő után se találtam megoldást, így most utolsó lehetőségként hozzátok fordulok :)

A probléma a következő: az IPTABLES script-emben van 1-2 kedves kis sor, ami ugye -j LOG paraméterre végződik ( --log-prefix -el megtámogatva ). Ezzel nincs is gond, szépen megy is.. Syslog-ng alatt beállítottam, hogy az "iptables" regexp-et tartalmazó szövegrészek menjenek szépen /var/log/iptables.log-ba..

A problémám ezzel a következő: Vannak olyan üzenetek, amelyek gond nélkül eljutnak eddig, ám vannak olyanok, amik a messages-ben illetve a syslog-ban landolnak, és ide nem jutnak tovább..
Mondanék nyomban 2 példát:
Messages-be kerül pl egy ilyen bejegyzés:
Feb 8 01:41:09 huncraft-pc kernel: iptables input eldobott: IN=ppp0 OUT= MAC= SRC=80.253.190.16 DST=CENSORED LEN=60 TOS=0x00 PREC=0x00 TTL=119 ID=30822 PROTO=ICMP TYPE=8 CODE=0 ID=512 SEQ=19456

iptables.log-ba pedig ilyen:
Feb 8 01:36:09 huncraft-pc iptables input eldobott: IN=ppp0 OUT= MAC= SRC=89.132.2.193 DST=CENSORED LEN=48 TOS=0x00 PREC=0x00 TTL=122 ID=45903 DF PROTO=TCP SPT=4565 DPT=51457 WINDOW=65535 RES=0x00 SYN URGP=0

A kettő között annyi különbség van, hogy a messages-hez menőt mintha a kernel küldené, de a syslog-ng.conf-ban meghatározott match "iptables" mintha arra már nem érvényesülne..

Itt a syslog-ng.conf-om hátha segít vmit..

    options { chain_hostnames(off); sync(0); };

    #source where to read log
    source src { unix-stream("/dev/log"); internal(); pipe ("/proc/kmsg"); };
    #source kernsrc { file("/proc/kmsg"); };

    #define destinations
    destination authlog { file("/var/log/auth.log"); };
    destination syslog { file("/var/log/syslog"); };
    destination cron { file("/var/log/cron.log"); };
    destination daemon { file("/var/log/daemon.log"); };
    destination kern { file("/var/log/kern.log"); };
    destination lpr { file("/var/log/lpr.log"); };
    destination user { file("/var/log/user.log"); };
    destination mail { file("/var/log/mail.log"); };
    destination iptables { file("/var/log/iptables.log"); };

    destination mailinfo { file("/var/log/mail.info"); };
    destination mailwarn { file("/var/log/mail.warn"); };
    destination mailerr { file("/var/log/mail.err"); };

    destination newscrit { file("/var/log/news/news.crit"); };destination newserr { file("/var/log/news/news.err"); };
    destination newsnotice { file("/var/log/news/news.notice"); };

    destination debug { file("/var/log/debug"); };
    destination messages { file("/var/log/messages"); };
    destination console { usertty("root"); };
    destination console_all { file("/dev/tty12"); };
    destination xconsole { pipe("/dev/xconsole"); };

    #create filters
    filter f_authpriv { facility(auth, authpriv); };
    filter f_syslog { facility(authpriv, mail);};
    filter f_cron { facility(cron); };
    filter f_daemon { facility(daemon); };
    filter f_kern { facility(kern); };
    filter f_lpr { facility(lpr); };
    filter f_mail { facility(mail); };
    filter f_user { facility(user); };
    filter f_debug { facility(auth, authpriv, news, mail); };
    filter f_iptables { match("iptables "); };
    filter f_messages { level(info..warn)
    and facility(auth, authpriv, mail, news); };
    filter f_emergency { level(emerg); };

    filter f_info { level(info); };
    filter f_notice { level(notice); };
    filter f_warn { level(warn); };
    filter f_crit { level(crit); };
    filter f_err { level(err); };
    filter f_failed { match("failed"); };
    filter f_denied { match("denied"); };

    #connect filter and destination
    log { source(src); filter(f_iptables); destination(iptables); };
    log { source(src); filter(f_authpriv); destination(authlog); };
    log { source(src); filter(f_syslog); destination(syslog); };
    log { source(src); filter(f_cron); destination(cron); };
    log { source(src); filter(f_daemon); destination(daemon); };
    log { source(src); filter(f_kern); destination(kern); };
    log { source(src); filter(f_lpr); destination(lpr); };
    log { source(src); filter(f_mail); destination(mail); };
    log { source(src); filter(f_user); destination(user); };
    log { source(src); filter(f_mail); filter(f_info); destination(mailinfo); };
    log { source(src); filter(f_mail); filter(f_warn); destination(mailwarn); };
    log { source(src); filter(f_mail); filter(f_err); destination(mailerr); };

    log { source(src); filter(f_debug); destination(debug); };log { source(src); filter(f_messages); destination(messages); };
    log { source(src); filter(f_emergency); destination(console); };

    log { source(src); destination(console_all); };

Találkoztatok ti már hasonló problémával??

Hozzászólások

Ez alapjan a konfig alapjan nehezen hiheto, de megnezned, nem fut-e veletlenul klogd is a gepen? A /proc/kmsg fura nalad, mivel pipe helyett file a szokasos, es ha a klogd futna, akkor a file ki is szolna, hogy nem nyert, mig a pipe lehet, hogy elnezobb... A kernel: prefixet a syslog-ng nem rakja bele magatol az uzenetekbe, igy en emiatt is futo klogd-re gyanakszom...

Hmmm.. Na ez érdekes..

    huncraft-pc:/home/huncraft# dpkg -l |grep klogd
    rc klogd 1.4.1-17 Kernel Logging Daemon
    rc sysklogd 1.4.1-17 System Logging Daemon
    huncraft-pc:/home/huncraft# ps aux |grep log
    root 118 0.0 0.0 0 0 ? S< 12:25 0:00 [xfslogd/0]
    root 4196 0.0 0.4 1896 544 ? Ss 12:26 0:00 /sbin/syslog-ng -p /var/run/syslog-ng.pid
    root 4961 0.0 0.4 3212 604 pts/0 S+ 12:32 0:00 grep log

szal elvileg a csomag fentvan igaz, de ne mfut.. mindenesetre most megpróbálom lekapni a kglod-t, hogy biztosra menjek..

Ami meg az zaphodb-t illeti: Nálam is minden LOG-olás prefix-ében ott van, hogy iptables-el kezdődjön, ezért se értem, hogy miért van az, hogy 2 ugyan olyan sorral kezdődő LOG más file-ba megy el..

____________________________________
Az embert 2 éven át arra tanítják hogyan álljon meg a 2 lábán, és hogyan beszéljen... Aztán azt mondják neki: -"Üllj le és kuss legyen!"..

nálam van egy and not match is ám, inkább ideteszem mindet alant. sztem

filter f_messages { level(info..warn)
and facility(auth, authpriv, mail, news); };

és

log { source(src); filter(f_messages); destination(messages); };

körül kell keresgélned.

szóval nálam:


# $Header: /var/cvsroot/gentoo-x86/app-admin/syslog-ng/files/syslog-ng.conf.gentoo,v 1.5 2005/05/12 05:46:10 mr_bones_ Exp $
#
# Syslog-ng default configuration file for Gentoo Linux
# contributed by Michael Sterrett

options { 
        chain_hostnames(off); 
        sync(0); 

        # The default action of syslog-ng 1.6.0 is to log a STATS line
        # to the file every 10 minutes.  That's pretty ugly after a while.
        # Change it to every 12 hours so you get a nice daily update of
        # how many messages syslog-ng missed (0).
        stats(43200); 
};

# ORIG
#source src { unix-stream("/dev/log"); internal(); pipe("/proc/kmsg"); };

#source where to read log
source src { unix-stream("/dev/log"); internal(); };
source kernsrc { file("/proc/kmsg"); };



# ORIG
#destination messages { file("/var/log/messages"); };
destination ipt { file("/var/log/iptables"); };

# By default messages are logged to tty12...
#destination console_all { file("/dev/tty12"); };
# ...if you intend to use /dev/console for programs like xconsole
# you can comment out the destination line above that references /dev/tty12
# and uncomment the line below.
#destination console_all { file("/dev/console"); };

#JOE
filter ipt { match("^IPTABLES "); };

#----------------------------------------------------

#define destinations
destination authlog { file("/var/log/auth.log"); };
destination syslog { file("/var/log/syslog"); };
destination cron { file("/var/log/cron.log"); };
destination daemon { file("/var/log/daemon.log"); };
destination kern { file("/var/log/kern.log"); };
destination lpr { file("/var/log/lpr.log"); };
destination user { file("/var/log/user.log"); };
destination mail { file("/var/log/mail.log"); };

destination mailinfo { file("/var/log/mail.info"); };
destination mailwarn { file("/var/log/mail.warn"); };
destination mailerr { file("/var/log/mail.err"); };

destination newscrit { file("/var/log/news/news.crit"); };
destination newserr { file("/var/log/news/news.err"); };
destination newsnotice { file("/var/log/news/news.notice"); };

destination debug { file("/var/log/debug"); };
destination messages { file("/var/log/messages"); };
#destination console { usertty("root"); };
#destination console_all { file("/dev/tty12"); };
#destination xconsole { pipe("/dev/xconsole"); };

#create filters
filter f_authpriv { facility(auth, authpriv); };
filter f_syslog { not facility(authpriv, mail); };
filter f_cron { facility(cron); };
filter f_daemon { facility(daemon); };
filter f_kern { facility(kern) and not match("^IPTABLES "); };
filter f_lpr { facility(lpr); };
filter f_mail { facility(mail); };
filter f_user { facility(user); };
filter f_debug { not facility(auth, authpriv, news, mail); };
#filter f_debug { not facility(auth, authpriv, mail); };
filter f_messages { level(info..warn) and not facility(auth, authpriv, mail, news); };
#filter f_messages { level(info..warn) and not facility(auth, authpriv, mail); };
filter f_emergency { level(emerg); };
filter f_info { level(info); };
filter f_notice { level(notice); };
filter f_warn { level(warn); };
filter f_crit { level(crit); };
filter f_err { level(err); };
filter f_failed { match("failed"); };
filter f_denied { match("denied"); };

#connect filter and destination
log { source(src); filter(f_authpriv); destination(authlog); };
log { source(src); filter(f_syslog); destination(syslog); };
log { source(src); filter(f_cron); destination(cron); };
log { source(src); filter(f_daemon); destination(daemon); };
log { source(kernsrc); filter(f_kern); destination(kern); };
log { source(src); filter(f_lpr); destination(lpr); };
log { source(src); filter(f_mail); destination(mail); };
log { source(src); filter(f_user); destination(user); };
log { source(src); filter(f_mail); filter(f_info); destination(mailinfo); };
log { source(src); filter(f_mail); filter(f_warn); destination(mailwarn); };
log { source(src); filter(f_mail); filter(f_err); destination(mailerr); };

log { source(src); filter(f_debug); destination(debug); };
log { source(src); filter(f_messages); destination(messages); };
#log { source(src); filter(f_emergency); destination(console); };


#----------------------------------------------------

# ORIG
#log { source(src); destination(messages); };

# JOE
log { source(kernsrc); filter(ipt); destination(ipt); };


#log { source(src); destination(console_all); };

Na.. egyenlőre megnéztem, hogy a 2 script között lévő változások ezt mennyire befolyásolják, szal majd reggelre kiderül ( sajna ilyen csomagot ami ott fennakad még nem sikerült generálnom ).

viszont 1 kérdésem lenne így logikai alapon: azzal a not match-al nem azt éred csak el, hogy ami amúgy a messages-be menne, az oda se menjen? ergo mintha azt amit amúgy logolna onnét kitiltod ( már ha jól értettem )?

____________________________________
Az embert 2 éven át arra tanítják hogyan álljon meg a 2 lábán, és hogyan beszéljen... Aztán azt mondják neki: -"Üllj le és kuss legyen!"..

Nos igen.. LÉnyegében ezzel tényleg azt értem el, hogy azok a logok, amik eddig messages-be mentek mostmár oda se mennek ( illetve iptables.log-ba se! ). .Ergo kevesebb infót kapok mostmár kézhez.. :S

____________________________________
Az embert 2 éven át arra tanítják hogyan álljon meg a 2 lábán, és hogyan beszéljen... Aztán azt mondják neki: -"Üllj le és kuss legyen!"..

Egyreszt ha ezt akarjatok, akkor arra ott a flags(final), es nem terhelitek feleslegesen a procit, masreszt nem kerultetek kozelebb a problema megoldasahoz ezzel a kiterovel. Szoval mi a helyzet a kerneltol erkezo uzenetekkel? A kernel: prefix honnan is jon? lsof /proc/kmsg, chroot-ok veletlenul nincsenek-e, stb.

nálam ezzel megy:

destination ipt { file("/var/log/iptables"); };

filter ipt { match("^IPTABLES "); };

filter f_kern { facility(kern) and not match("^IPTABLES "); };

log { source(kernsrc); filter(ipt); destination(ipt); };

gondolom megadtam valahol hogy IPTABLES-el kezdődjön minden iptables által írt sor.