Przeniesienie logow iptables do osobnego pliku.

Ogólne pytania dotyczące systemu
Matrixx
Beginner
Posty: 235
Rejestracja: 03 maja 2016, 16:30

Re: Przeniesienie logow iptables do osobnego pliku.

Post autor: Matrixx »

Wykonane

Kod: Zaznacz cały

#  Default rules for rsyslog.
#
#                       For more information see rsyslog.conf(5) and /etc/rsyslog.conf

#
# First some standard log files.  Log by facility.
#
if $msg contains 'ipT4: ' then -/var/log/iptables.log
& stop
auth,authpriv.*                 /var/log/auth.log
*.*;auth,authpriv.none          -/var/log/syslog
#cron.*                         /var/log/cron.log
#daemon.*                       -/var/log/daemon.log

#lpr.*                          -/var/log/lpr.log
mail.*                          -/var/log/mail.log
#user.*                         -/var/log/user.log

#
# Logging for the mail system.  Split it up so that
# it is easy to write scripts to parse these files.
#
#mail.info                      -/var/log/mail.info
#mail.warn                      -/var/log/mail.warn
mail.err                        /var/log/mail.err

#
# Logging for INN news system.
#
news.crit                       /var/log/news/news.crit
news.err                        /var/log/news/news.err
news.notice                     -/var/log/news/news.notice

#
# Some "catch-all" log files.
#
#*.=debug;\
#       auth,authpriv.none;\
#       news.none;mail.none     -/var/log/debug
#*.=info;*.=notice;*.=warn;\
#       auth,authpriv.none;\
#       cron,daemon.none;\
#       mail,news.none          -/var/log/messages

#
# Emergencies are sent to everybody logged in.
#
*.emerg                                :omusrmsg:*

#
# I like to have messages displayed on the console, but only on a virtual
# console I usually leave idle.
#
#daemon,mail.*;\
#       news.=crit;news.=err;news.=notice;\
#       *.=debug;*.=info;\
#       *.=notice;*.=warn       /dev/tty8

# The named pipe /dev/xconsole is for the `xconsole' utility.  To use it,
# you must invoke `xconsole' with the `-file' option:
#
#    $ xconsole -file /dev/xconsole [...]
#
# NOTE: adjust the list below, or you'll go crazy if you have a reasonably
#      busy site..
#
#daemon.*;mail.*;\
#       news.err;\
#       *.=debug;*.=info;\
#       *.=notice;*.=warn       |/dev/xconsole
Awatar użytkownika
Morfik
Beginner
Posty: 149
Rejestracja: 21 lutego 2009, 21:00

Re: Przeniesienie logow iptables do osobnego pliku.

Post autor: Morfik »

I w czym problem teraz? :D
Awatar użytkownika
marcin1982
Moderator
Posty: 1730
Rejestracja: 05 maja 2011, 12:59
Lokalizacja: Zagłębie Dąbrowskie

Re: Przeniesienie logow iptables do osobnego pliku.

Post autor: marcin1982 »

W dalszym ciągu masz błędną definicję:

Kod: Zaznacz cały

if $msg contains 'ipT4: ' then -/var/log/iptables.log
& stop
Awatar użytkownika
Morfik
Beginner
Posty: 149
Rejestracja: 21 lutego 2009, 21:00

Re: Przeniesienie logow iptables do osobnego pliku.

Post autor: Morfik »

I gdzie ten błąd? Bo ja używam szeregu warunków, w tym jeden z rozdzielaniem logów iptables do osobnego pliku i u mnie bez problemu działa. :D
Matrixx
Beginner
Posty: 235
Rejestracja: 03 maja 2016, 16:30

Re: Przeniesienie logow iptables do osobnego pliku.

Post autor: Matrixx »

Teraz nawet nie loguje do sysloga.
Awatar użytkownika
marcin1982
Moderator
Posty: 1730
Rejestracja: 05 maja 2011, 12:59
Lokalizacja: Zagłębie Dąbrowskie

Re: Przeniesienie logow iptables do osobnego pliku.

Post autor: marcin1982 »

Morfik
Ok. Oparłem się na tym, co pisał pawkrol tutaj:
viewtopic.php?f=5&t=34799#p194161

Ja mam bez warunków i też działa ... po co komplikować.
Matrixx
Beginner
Posty: 235
Rejestracja: 03 maja 2016, 16:30

Re: Przeniesienie logow iptables do osobnego pliku.

Post autor: Matrixx »

Wklejam jeszcze raz:
/etc/rsyslog.d/50-default.conf

Kod: Zaznacz cały

#  Default rules for rsyslog.
#
#                       For more information see rsyslog.conf(5) and /etc/rsysl$

#
# First some standard log files.  Log by facility.
#
if $msg contains 'ipT4: ' then -/var/log/iptables.log
& stop
auth,authpriv.*                 /var/log/auth.log
*.*;auth,authpriv.none          -/var/log/syslog
#cron.*                         /var/log/cron.log
#daemon.*                       -/var/log/daemon.log

#lpr.*                          -/var/log/lpr.log
mail.*                          -/var/log/mail.log
#user.*                         -/var/log/user.log

#
# Logging for the mail system.  Split it up so that
# it is easy to write scripts to parse these files.
#
#mail.info                      -/var/log/mail.info
#mail.warn                      -/var/log/mail.warn
mail.err                        /var/log/mail.err

#
# Logging for INN news system.
#
news.crit                       /var/log/news/news.crit
news.err                        /var/log/news/news.err
news.notice                     -/var/log/news/news.notice

#
# Some "catch-all" log files.
#
#*.=debug;\
#       auth,authpriv.none;\
#       news.none;mail.none     -/var/log/debug
#*.=info;*.=notice;*.=warn;\
#       auth,authpriv.none;\
#       cron,daemon.none;\
#       mail,news.none          -/var/log/messages

#
# Emergencies are sent to everybody logged in.
#
*.emerg                                :omusrmsg:*

#
# I like to have messages displayed on the console, but only on a virtual
# console I usually leave idle.
#
#daemon,mail.*;\
#       news.=crit;news.=err;news.=notice;\
#       *.=debug;*.=info;\
#       *.=notice;*.=warn       /dev/tty8

# The named pipe /dev/xconsole is for the `xconsole' utility.  To use it,
# you must invoke `xconsole' with the `-file' option:
#
#    $ xconsole -file /dev/xconsole [...]
#
# NOTE: adjust the list below, or you'll go crazy if you have a reasonably
#      busy site..
#
#daemon.*;mail.*;\
#       news.err;\
#       *.=debug;*.=info;\
#       *.=notice;*.=warn       |/dev/xconsole
Moze zrobic:

Kod: Zaznacz cały

sudo apt-get install --reinstall rsyslog
Awatar użytkownika
Morfik
Beginner
Posty: 149
Rejestracja: 21 lutego 2009, 21:00

Re: Przeniesienie logow iptables do osobnego pliku.

Post autor: Morfik »

No działanie tej mojej regułki jest następujące:
Gdy pojawi się wiadomość, która zawiera 'ipT4: ', to cały komunikat trzeba przesłać do pliku /var/log/iptables.log . Jednocześnie ma nastąpić zatrzymanie przetwarzania komunikatu i za to odpowiada & stop . Bez tego & stop, komunikat by został przetworzony przez następne reguły.

Z tego co pamiętam, to plik musi istnieć chyba.
Awatar użytkownika
marcin1982
Moderator
Posty: 1730
Rejestracja: 05 maja 2011, 12:59
Lokalizacja: Zagłębie Dąbrowskie

Re: Przeniesienie logow iptables do osobnego pliku.

Post autor: marcin1982 »

Z tego co pamiętam, to plik musi istnieć chyba.
Z tym nie ma problemu - w razie wystąpienia zdarzenia plik zostanie utworzony zgodnie z dyrektywami głównego pliku rsyslog.conf. Oczywiście po zmianie konfiguracji trzeba zrestartować rsyslog.
Matrixx
Beginner
Posty: 235
Rejestracja: 03 maja 2016, 16:30

Re: Przeniesienie logow iptables do osobnego pliku.

Post autor: Matrixx »

To jak zrobic konfig zeby majac 4 rozne suffixy w pliku konfigu regol iptables (jak jest u mnie aktualnie) logi byly zapisywane w 4 grupach suffiksow a nie wymieszane razem?
Ostatnio zmieniony 19 września 2017, 18:38 przez Matrixx, łącznie zmieniany 1 raz.
ODPOWIEDZ