Nie jesteś zalogowany.
Jeśli nie posiadasz konta, zarejestruj je już teraz! Pozwoli Ci ono w pełni korzystać z naszego serwisu. Spamerom dziękujemy!
Prosimy o pomoc dla małej Julki — przekaż 1% podatku na Fundacji Dzieciom zdazyć z Pomocą.
Więcej informacji na dug.net.pl/pomagamy/.
Strony: 1
Aktualnie nie korzystam z uslugi iptables w systemd.
Zamiast tego mam plik: /etc/network/if-pre-up.d/firewall.
Problemem jest, ze wszystkie logi iptables laduja wymieszane z innymi logami w lokalizacji /var/log/....
Chcialbym je wydzielic do osobnego pliku, moze byc w tej samej lokalizacji.
Jak to zrobic, zeby dzialalo?
Ostatnio edytowany przez Novi-cjusz (2016-05-16 11:51:20)
Offline
W /etc/rsyslog.conf se dodaj na początku przed innymi obiektami takie coś
if $msg contains 'IPTABLES:' then -/var/log/iptables.log & stop
I se dostosuj to co jest w apostrofach.
Offline
[quote=morfik]W /etc/rsyslog.conf se dodaj na początku przed innymi obiektami takie coś
if $msg contains 'IPTABLES:' then -/var/log/iptables.log & stop
I se dostosuj to co jest w apostrofach.[/quote]
Nic nie zobaczy w ten sposób:
May 11 20:54:46 localhost kernel: [ 4346.127269] Zablokowany OUTPUT IN= OUT=eth0 SRC=182.168.0.5 DST=208.78.71.14 LEN=83 TOS=0x00 PREC=0x00 TTL=128 ID=46941 PROTO=UDP SPT=50905 DPT=53 LEN=63
Nie widzę tu nazwy Iptables, jest kernel.
Regułka, która wygenerowała loga ma postać:
-A OUTPUT -o eth+ -j LOG --log-prefix "Zablokowany OUTPUT "
Blokuje polityka domyślna:
-P OUTPUT DROP
Wytargać z loga albo z dmesg można przez wygrepowanie albo regex prefixu.
http://kb.monitorware.com/regular-expressions-with-rsyslogd-t10055.html
http://www.rsyslog.com/regex/
Pozdro
Ostatnio edytowany przez Jacekalex (2016-05-13 21:42:21)
Offline
@Jacekalex, okulista chyba cię czeka: xD
[quote=morfik]I se dostosuj to co jest w apostrofach.[/quote]
Ja po prostu używam prefixów przy logach iptables. Zwykle tam umieszczam IPTABLES i na podstawie tego rozdzielam.
Ostatnio edytowany przez morfik (2016-05-14 10:25:49)
Offline
Moj plik iptables nazywa sie "firewall" i siedzi w lokalizacji " /etc/network/if-pre-up.d/firewall "
Oto jego tresc:
root@debian:/etc/network/if-pre-up.d# cat firewall #!/bin/sh iptables -F iptables -X # what was incoming but denied (optional but useful). iptables -A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables_INPUT_denied: " --log-level 7 iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT iptables -P INPUT DROP # Log any traffic which was sent to you # for forwarding (optional but useful). iptables -A FORWARD -m limit --limit 5/min -j LOG --log-prefix "iptables_FORWARD_denied: " --log-level 7 iptables -P FORWARD DROP iptables -I OUTPUT -m conntrack --ctstate NEW,INVALID -j LOG --log-prefix "OUTPUT" iptables -P OUTPUT ACCEPT ip6tables -F ip6tables -X # Log what was incoming but denied (optional but useful). ip6tables -A INPUT -m limit --limit 5/min -j LOG --log-prefix "ip6tables_INPUT_denied: " --log-level 7 ip6tables -A INPUT -i lo -j ACCEPT ip6tables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT ip6tables -P INPUT DROP # Log any traffic which was sent to you # for forwarding (optional but useful). ip6tables -A FORWARD -m limit --limit 5/min -j LOG --log-prefix "ip6tables_FORWARD_denied: " --log-level 7 ip6tables -P FORWARD DROP ip6tables -P OUTPUT ACCEPT root@debian:/etc/network/if-pre-up.d#
Prefixow w nim rowno 5.
W /etc/rsyslog.conf zmodyfikowalem nastepujaco:
GNU nano 2.2.6 File: /etc/rsyslog.conf Modified $IncludeConfig /etc/rsyslog.d/*.conf ############### #### RULES #### ############### # # First some standard log files. Log by facility. # if $msg contains 'iptables_INPUT:' 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 kern.* -/var/log/kern.log lpr.* -/var/log/lpr.log mail.* -/var/log/mail.log [ line 61/124 (49%), col 33/63 (52%), char 1204/2702 (44%) ] ^G Get Help ^O WriteOut ^R Read File ^Y Prev Page ^K Cut Text ^C Cur Pos ^X Exit ^J Justify ^W Where Is ^V Next Page ^U UnCut Text^T To Spell
Restart.
Niestety nie pojawil sie niezalezny plik zawierajacy wylacznie logi iptables.
root@debian:/var/log# ls alternatives.log debug.2.gz lpr.log.2.gz messages.1 alternatives.log.1 debug.3.gz lpr.log.3.gz messages.2.gz alternatives.log.2.gz debug.4.gz lpr.log.4.gz messages.3.gz apt dmesg mail.err messages.4.gz aptitude dpkg.log mail.err.1 plot aptitude.1.gz dpkg.log.1 mail.err.2.gz speech-dispatcher aptitude.2.gz dpkg.log.2.gz mail.err.3.gz syslog auth.log exim4 mail.err.4.gz syslog.1 auth.log.1 faillog mail.info syslog.2.gz auth.log.2.gz firebird mail.info.1 syslog.3.gz auth.log.3.gz fontconfig.log mail.info.2.gz syslog.4.gz auth.log.4.gz fsck mail.info.3.gz syslog.5.gz boot gdm3 mail.info.4.gz syslog.6.gz boot-sav hp mail.log syslog.7.gz btmp installer mail.log.1 user.log btmp.1 kern.log mail.log.2.gz user.log.1 cups kern.log.1 mail.log.3.gz user.log.2.gz daemon.log kern.log.2.gz mail.log.4.gz user.log.3.gz daemon.log.1 kern.log.3.gz mail.warn user.log.4.gz daemon.log.2.gz kern.log.4.gz mail.warn.1 wifi-radar.log daemon.log.3.gz lastlog mail.warn.2.gz wtmp daemon.log.4.gz libvirt mail.warn.3.gz wtmp.1 debug lpr.log mail.warn.4.gz Xorg.0.log debug.1 lpr.log.1 messages Xorg.0.log.old root@debian:/var/log#
Rsyslog dziala:
root@debian:/var/log# systemctl status service rsyslog ● service.service Loaded: not-found (Reason: No such file or directory) Active: inactive (dead) ● rsyslog.service - System Logging Service Loaded: loaded (/lib/systemd/system/rsyslog.service; enabled) Active: active (running) since Sun 2016-05-15 09:43:52 IST; 31s ago Docs: man:rsyslogd(8) http://www.rsyslog.com/doc/ Main PID: 2801 (rsyslogd) CGroup: /system.slice/rsyslog.service └─2801 /usr/sbin/rsyslogd -n
A przy okazji pojawilo sie pytanie, jezeli jest 5 prefixow to jak je najskuteczniej zastosowac w pliku rsyslog.conf?
Przegladajac plik " syslog " przyszlo mi do glowy, ze to moze byc nieporozumienie, poniewaz aktualnie w ramach pliku syslog logi iptables sa grupowane, przyklad:
PROTO=UDP SPT=53 DPT=58425 LEN=61 May 15 09:49:38 debian kernel: [ 2819.086146] iptables_INPUT_denied: IN=eth0 OUT= MAC=60:a4:4c:64:a8:bd:00:0b:00:00:ad:d0:08:00 SRC=192.168.0.1 DST=192.168.0.182 LEN=93 TOS=0x00 PREC=0x00 TTL=64 ID=32142 PROTO=UDP SPT=53 DPT=58425 LEN=73 May 15 09:49:38 debian kernel: [ 2819.086546] OUTPUTIN= OUT=eth0 SRC=192.168.0.182 DST=190.15.141.36 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=3156 DF PROTO=TCP SPT=53296 DPT=443 WINDOW=29200 RES=0x00 SYN URGP=0 May 15 09:49:38 debian kernel: [ 2819.270352] iptables_INPUT_denied: IN=eth0 OUT= MAC=60:a4:4c:64:a8:bd:00:0b:00:00:ad:d0:08:00 SRC=190.15.141.36 DST=192.168.0.182 LEN=60 TOS=0x00 PREC=0x00 TTL=44 ID=0 DF PROTO=TCP SPT=443 DPT=53296 WINDOW=14480 RES=0x00 ACK SYN URGP=0 May 15 09:49:38 debian kernel: [ 2819.454873] iptables_INPUT_denied: IN=eth0 OUT= MAC=60:a4:4c:64:a8:bd:00:0b:00:00:ad:d0:08:00 SRC=190.15.141.36 DST=192.168.0.182 LEN=52 TOS=0x00 PREC=0x00 TTL=44 ID=46915 DF PROTO=TCP SPT=443 DPT=53296 WINDOW=31 RES=0x00 ACK URGP=0 May 15 09:49:38 debian kernel: [ 2819.454930] iptables_INPUT_denied: IN=eth0 OUT= MAC=60:a4:4c:64:a8:bd:00:0b:00:00:ad:d0:08:00 SRC=190.15.141.36 DST=192.168.0.182 LEN=2868 TOS=0x00 PREC=0x00 TTL=45 ID=14149 DF PROTO=TCP SPT=443 DPT=53296 WINDOW=31 RES=0x00 ACK URGP=0 May 15 09:49:38 debian kernel: [ 2819.460820] OUTPUTIN= OUT=eth0 SRC=192.168.0.182 DST=192.168.0.1 LEN=62 TOS=0x00 PREC=0x00 TTL=64 ID=17438 DF PROTO=UDP SPT=63209 DPT=53 LEN=42 May 15 09:49:38 debian kernel: [ 2819.460852] OUTPUTIN= OUT=eth0 SRC=192.168.0.182 DST=192.168.0.1 LEN=62 TOS=0x00 PREC=0x00 TTL=64 ID=17439 DF PROTO=UDP SPT=63209 DPT=53 LEN=42 May 15 09:49:38 debian kernel: [ 2819.461005] OUTPUTIN= OUT=eth0 SRC=192.168.0.182 DST=192.168.0.1 LEN=62 TOS=0x00 PREC=0x00 TTL=64 ID=17440 DF PROTO=UDP SPT=60336 DPT=53 LEN=42 May 15 09:49:38 debian kernel: [ 2819.491652] OUTPUTIN= OUT=eth0 SRC=192.168.0.182 DST=188.121.36.239 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=10043 DF PROTO=TCP SPT=50430 DPT=80 WINDOW=29200 RES=0x00 SYN URGP=0 May 15 09:49:50 debian kernel: [ 2831.526335] iptables_INPUT_denied: IN=eth0 OUT= MAC=60:a4:4c:64:a8:bd:00:0b:00:00:ad:d0:08:00 SRC=190.15.141.36 DST=192.168.0.182 LEN=52 TOS=0x00 PREC=0x00 TTL=44 ID=47238 DF PROTO=TCP SPT=443 DPT=53296 WINDOW=35 RES=0x00 ACK URGP=0 May 15 09:49:54 debian kernel: [ 2834.707058] ip6tables_INPUT_denied: IN=eth0 OUT= MAC=33:33:00:00:00:01:00:0b:00:00:ad:d0:86:dd SRC=fe80:0000:0000:0000:020b:00ff:fe00:add0 DST=ff02:0000:0000:0000:0000:0000:0000:0001 LEN=120 TC=0 HOPLIMIT=255 FLOWLBL=0 PROTO=ICMPv6 TYPE=134 CODE=0 May 15 09:49:56 debian gnome-session[1532]: ** (zeitgeist-datahub:1716): WARNING **: recent-manager-provider.vala:132: Desktop file for "file:///home/robin/Downloads/novi@jabbim.cz.tar.xz" was not found, exec: Pidgin, mime_type: application/octet-stream May 15 09:49:56 debian gnome-session[1532]: ** (zeitgeist-datahub:1716): WARNING **: recent-manager-provider.vala:132: Desktop file for "file:///cgroup/cgrules.conf" was not found, exec: soffice, mime_type: application/octet-stream May 15 09:49:56 debian gnome-session[1532]: ** (zeitgeist-datahub:1716): WARNING **: recent-manager-provider.vala:132: Desktop file for "file:///home/robin/Documents/___%20PROJEKTY../---%20Projekt_Cgroups/---%20Cgstart.service=skrypt_startowy./cgstart.service" was not found, exec: soffice, mime_type: application/octet-stream May 15 09:49:56 debian gnome-session[1532]: ** (zeitgeist-datahub:1716): WARNING **: recent-manager-provider.vala:132: Desktop file for "file:///home/robin/Documents/___%20PROJEKTY../---%20Projekt_Cgroups/---%20Cgstart_skrypt./cgstart" was not found, exec: soffice, mime_type: application/octet-stream May 15 09:49:56 debian gnome-session[1532]: ** (zeitgeist-datahub:1716): WARNING **: recent-manager-provider.vala:132: Desktop file for "file:///home/robin/Documents/___%20PROJEKTY../---%20Projekt_Cgroups/---%20Cgrulesngd/cgrulesengd" was not found, exec: soffice, mime_type: application/octet-stream May 15 09:49:56 debian gnome-session[1532]: ** (zeitgeist-datahub:1716): WARNING **: recent-manager-provider.vala:132: Desktop file for "file:///etc/cgrules.conf" was not found, exec: soffice, mime_type: application/octet-stream May 15 09:50:02 debian kernel: [ 2842.972082] OUTPUTIN= OUT=eth0 SRC=192.168.0.182 DST=192.168.0.1 LEN=62 TOS=0x00 PREC=0x00 TTL=64 ID=21766 DF PROTO=UDP SPT=54528 DPT=53 LEN=42 May 15 09:50:02 debian kernel: [ 2842.972102] OUTPUTIN= OUT=eth0 SRC=192.168.0.182 DST=192.168.0.1 LEN=62 TOS=0x00 PREC=0x00 TTL=64 ID=21767 DF PROTO=UDP SPT=54528 DPT=53 LEN=42 May 15 09:50:02 debian kernel: [ 2842.972244] OUTPUTIN= OUT=eth0 SRC=192.168.0.182 DST=192.168.0.1 LEN=70 TOS=0x00 PREC=0x00 TTL=64 ID=21768 DF PROTO=UDP SPT=62690 DPT=53 LEN=50 May 15 09:50:02 debian kernel: [ 2842.972293] OUTPUTIN= OUT=eth0 SRC=192.168.0.182 DST=192.168.0.1 LEN=70 TOS=0x00 PREC=0x00 TTL=64 ID=21769 DF PROTO=UDP SPT=62690 DPT=53 LEN=50 May 15 09:50:02 debian kernel: [ 2842.978012] OUTPUTIN= OUT=eth0 SRC=192.168.0.182 DST=46.105.189.254 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=17360 DF PROTO=TCP SPT=64956 DPT=443 WINDOW=29200 RES=0x00 SYN URGP=0 May 15 09:50:02 debian kernel: [ 2842.978424] OUTPUTIN= OUT=eth0 SRC=192.168.0.182 DST=46.105.189.254 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=64038 DF PROTO=TCP SPT=64958 DPT=443 WINDOW=29200 RES=0x00 SYN URGP=0 May 15 09:50:02 debian kernel: [ 2842.978535] OUTPUTIN= OUT=eth0 SRC=192.168.0.182 DST=192.168.0.1 LEN=70 TOS=0x00 PREC=0x00 TTL=64 ID=21771 DF PROTO=UDP SPT=62292 DPT=53 LEN=50 May 15 09:50:02 debian kernel: [ 2842.978616] OUTPUTIN= OUT=eth0 SRC=192.168.0.182 DST=46.105.189.254 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=12547 DF PROTO=TCP SPT=64960 DPT=443 WINDOW=29200 RES=0x00 SYN URGP=0 May 15 09:50:02 debian kernel: [ 2842.978738] OUTPUTIN= OUT=eth0 SRC=192.168.0.182 DST=46.105.189.254 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=13603 DF PROTO=TCP SPT=64962 DPT=443 WINDOW=29200 RES=0x00 SYN URGP=0 May 15 09:50:02 debian kernel: [ 2842.978882] OUTPUTIN= OUT=eth0 SRC=192.168.0.182 DST=46.105.189.254 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=51402 DF PROTO=TCP SPT=64964 DPT=443 WINDOW=29200 RES=0x00 SYN URGP=0 May 15 09:50:02 debian kernel: [ 2843.003580] OUTPUTIN= OUT=eth0 SRC=192.168.0.182 DST=216.58.211.168 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=44799 DF PROTO=TCP SPT=59538 DPT=443 WINDOW=29200 RES=0x00 SYN URGP=0 May 15 09:50:02 debian kernel: [ 2843.096809] iptables_INPUT_denied: IN=eth0 OUT= MAC=60:a4:4c:64:a8:bd:00:0b:00:00:ad:d0:08:00 SRC=216.58.211.168 DST=192.168.0.182 LEN=52 TOS=0x00 PREC=0x00 TTL=58 ID=37564 PROTO=TCP SPT=443 DPT=59538 WINDOW=350 RES=0x00 ACK URGP=0 May 15 09:51:01 debian kernel: [ 2901.993723] iptables_INPUT_denied: IN=eth0 OUT= MAC=60:a4:4c:64:a8:bd:00:0b:00:00:ad:d0:08:00 SRC=216.58.211.168 DST=192.168.0.182 LEN=52 TOS=0x00 PREC=0x00 TTL=57 ID=62724 PROTO=TCP SPT=443 DPT=59538 WINDOW=350 RES=0x00 ACK URGP=0 May 15 09:51:01 debian kernel: [ 2901.998811] iptables_INPUT_denied: IN=eth0 OUT= MAC=60:a4:4c:64:a8:bd:00:0b:00:00:ad:d0:08:00 SRC=216.58.211.168 DST=192.168.0.182 LEN=112 TOS=0x00 PREC=0x00 TTL=57 ID=62725 PROTO=TCP SPT=443 DPT=59538 WINDOW=350 RES=0x00 ACK PSH URGP=0 May 15 09:51:01 debian kernel: [ 2901.998846] iptables_INPUT_denied: IN=eth0 OUT= MAC=60:a4:4c:64:a8:bd:00:0b:00:00:ad:d0:08:00 SRC=216.58.211.168 DST=192.168.0.182 LEN=52 TOS=0x00 PREC=0x00 TTL=57 ID=62726 PROTO=TCP SPT=443 DPT=59538 WINDOW=350 RES=0x00 ACK FIN URGP=0 May 15 09:51:01 debian kernel: [ 2902.008574] iptables_INPUT_denied: IN=eth0 OUT= MAC=60:a4:4c:64:a8:bd:00:0b:00:00:ad:d0:08:00 SRC=216.58.211.168 DST=192.168.0.182 LEN=40 TOS=0x00 PREC=0x00 TTL=57 ID=62729 PROTO=TCP SPT=443 DPT=59538 WINDOW=0 RES=0x00 RST URGP=0
Ja wyobrazalem sobie np plik " firewall " gdzie sa wylacznie logi iptables uporzadkowane wg prefixow, co bardzo ulatwiloby analize trafficu.
Ostatnio edytowany przez Novi-cjusz (2016-05-15 11:04:51)
Offline
3009
Ostatnio edytowany przez uzytkownikubunt (2016-12-01 01:40:46)
Offline
Prefix dostosuj prawidłowo w /etc/rsyslog.conf . Poza tym, testuj sobie komunikaty za pomocą
# logger -t rsyslog IPTABLES:
Faktycznie plik trzeba pierw stworzyć sobie ręcznie. Dopiero wtedy rsyslog będzie na nim operował.
Offline
Zmodyfikowalem rsyslog.conf
root@debian:/etc# cat rsyslog.conf # /etc/rsyslog.conf Configuration file for rsyslog. # # For more information see # /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html ################# #### MODULES #### ################# $ModLoad imuxsock # provides support for local system logging $ModLoad imklog # provides kernel logging support #$ModLoad immark # provides --MARK-- message capability # provides UDP syslog reception #$ModLoad imudp #$UDPServerRun 514 # provides TCP syslog reception #$ModLoad imtcp #$InputTCPServerRun 514 ########################### #### GLOBAL DIRECTIVES #### ########################### # # Use traditional timestamp format. # To enable high precision timestamps, comment out the following line. # $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat # # Set the default permissions for all log files. # $FileOwner root $FileGroup adm $FileCreateMode 0640 $DirCreateMode 0755 $Umask 0022 # # Where to place spool and state files # $WorkDirectory /var/spool/rsyslog # # Include all config files in /etc/rsyslog.d/ # $IncludeConfig /etc/rsyslog.d/*.conf ############### #### RULES #### ############### # # First some standard log files. Log by facility. # if $msg contains iptables_INPUT: then -/var/log/firewall & stop auth,authpriv.* /var/log/auth.log *.*;auth,authpriv.none -/var/log/syslog #cron.* /var/log/cron.log daemon.* -/var/log/daemon.log kern.* -/var/log/kern.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 root@debian:/etc#
Stworzylem plik:
touch /var/log/firewall
Nadalem prawa wykonywania:
chmod +x /var/log/firewall
Plik powstal, ale jest pusty:
Ostatnio edytowany przez Novi-cjusz (2016-05-15 12:48:59)
Offline
3011
Ostatnio edytowany przez uzytkownikubunt (2016-12-01 01:40:49)
Offline
Kolejna zmiana rsyslog.conf:
root@debian:/etc# cat rsyslog.conf # /etc/rsyslog.conf Configuration file for rsyslog. # # For more information see # /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html ################# #### MODULES #### ################# $ModLoad imuxsock # provides support for local system logging $ModLoad imklog # provides kernel logging support #$ModLoad immark # provides --MARK-- message capability # provides UDP syslog reception #$ModLoad imudp #$UDPServerRun 514 # provides TCP syslog reception #$ModLoad imtcp #$InputTCPServerRun 514 ########################### #### GLOBAL DIRECTIVES #### ########################### # # Use traditional timestamp format. # To enable high precision timestamps, comment out the following line. # $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat # # Set the default permissions for all log files. # $FileOwner root $FileGroup adm $FileCreateMode 0640 $DirCreateMode 0755 $Umask 0022 # # Where to place spool and state files # $WorkDirectory /var/spool/rsyslog # # Include all config files in /etc/rsyslog.d/ # $IncludeConfig /etc/rsyslog.d/*.conf ############### #### RULES #### ############### # # First some standard log files. Log by facility. # if $msg contains iptables_INPUT: then -/var/log/firewall auth,authpriv.* /var/log/auth.log *.*;auth,authpriv.none -/var/log/syslog #cron.* /var/log/cron.log daemon.* -/var/log/daemon.log kern.* -/var/log/kern.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 root@debian:/etc#
Prawa do wykonywania to blad (byloby dobre dla skryptu).
Wazne sa prawa zapisu, szeroko pojete, wiec:
chmod 755 /var/log/firewall
root@debian:/var/log# ls -l firewall -rwxr-xr-x 1 root root 0 May 15 11:05 firewall
Ostatnio edytowany przez Novi-cjusz (2016-05-15 13:30:29)
Offline
Tak mam w poscie #10
if $msg contains iptables_INPUT: then -/var/log/firewall
Ostatnio edytowany przez Novi-cjusz (2016-05-15 14:04:53)
Offline
peln prefix jest:
"iptables_INPUT_denied: "
wpisac z apostrofami?
Offline
Przecie na samym początku ci podałem linijkę z apostrofami, to czemu je ściągnąłeś?
http://www.rsyslog.com/doc/v8-stable/configuration/filters.html
Ostatnio edytowany przez morfik (2016-05-15 14:11:53)
Offline
Juz naprawilem:
############### #### RULES #### ############### # # First some standard log files. Log by facility. # if $msg contains 'iptables_INPUT_denied:' then -/var/log/firewall auth,authpriv.* /var/log/auth.log *.*;auth,authpriv.none -/var/log/syslog #cron.* /var/log/cron.log daemon.* -/var/log/daemon.log kern.* -/var/log/kern.log
Zatrybilo!!(:-)
May 15 13:25:16 morfikownia kernel: [ 18.557786] iptables_INPUT_denied: IN=lo OUT= MAC=00:00:00:00:00:00:00:00:00:00:00:00:08:00 SRC=127.0.0.1 DST=127.0.0.1 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=36375 DF PROTO=TCP SPT=51244 DPT=631 WINDOW=40960 RES=0x00 SYN URGP=0 May 15 13:25:16 morfikownia kernel: [ 18.557820] iptables_INPUT_denied: IN=lo OUT= MAC=00:00:00:00:00:00:00:00:00:00:00:00:08:00 SRC=127.0.0.1 DST=127.0.0.1 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=23976 DF PROTO=TCP SPT=631 DPT=51244 WINDOW=0 RES=0x00 ACK RST URGP=0 May 15 13:25:17 morfikownia kernel: [ 19.560717] iptables_INPUT_denied: IN=lo OUT= MAC=00:00:00:00:00:00:00:00:00:00:00:00:08:00 SRC=127.0.0.1 DST=127.0.0.1 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=22686 DF PROTO=TCP SPT=51246 DPT=631 WINDOW=40960 RES=0x00 SYN URGP=0 May 15 13:25:17 morfikownia kernel: [ 19.560751] iptables_INPUT_denied: IN=lo OUT= MAC=00:00:00:00:00:00:00:00:00:00:00:00:08:00 SRC=127.0.0.1 DST=127.0.0.1 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=24758 DF PROTO=TCP SPT=631 DPT=51246 WINDOW=0 RES=0x00 ACK RST URGP=0 May 15 13:25:18 morfikownia kernel: [ 20.562644] iptables_INPUT_denied: IN=lo OUT= MAC=00:00:00:00:00:00:00:00:00:00:00:00:08:00 SRC=127.0.0.1 DST=127.0.0.1 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=7108 DF PROTO=TCP SPT=51248 DPT=631 WINDOW=40960 RES=0x00 SYN URGP=0 May 15 13:25:20 morfikownia kernel: [ 23.334366] iptables_INPUT_denied: IN=eth0 OUT= MAC= SRC=192.168.0.182 DST=224.0.0.251 LEN=239 TOS=0x00 PREC=0x00 TTL=255 ID=8351 DF PROTO=UDP SPT=5353 DPT=5353 LEN=219 May 15 13:25:20 morfikownia kernel: [ 23.341164] iptables_INPUT_denied: IN=eth0 OUT= MAC= SRC=192.168.0.182 DST=192.168.0.255 LEN=44 TOS=0x00 PREC=0x00 TTL=64 ID=52611 DF PROTO=UDP SPT=8612 DPT=8612 LEN=24 May 15 13:25:20 morfikownia kernel: [ 23.351341] iptables_INPUT_denied: IN=eth0 OUT= MAC= SRC=192.168.0.182 DST=192.168.0.255 LEN=44 TOS=0x00 PREC=0x00 TTL=64 ID=52617 DF PROTO=UDP SPT=8612 DPT=8612 LEN=24 May 15 13:25:21 morfikownia kernel: [ 23.585014] iptables_INPUT_denied: IN=eth0 OUT= MAC= SRC=192.168.0.182 DST=224.0.0.251 LEN=239 TOS=0x00 PREC=0x00 TTL=255 ID=8541 DF PROTO=UDP SPT=5353 DPT=5353 LEN=219 May 15 13:25:21 morfikownia kernel: [ 23.642633] iptables_INPUT_denied: IN=eth0 OUT= MAC=60:a4:4c:64:a8:bd:00:0b:00:00:ad:d0:08:00 SRC=192.168.0.1 DST=192.168.0.182 LEN=126 TOS=0x00 PREC=0x00 TTL=64 ID=35824 PROTO=UDP SPT=53 DPT=61711 LEN=106 May 15 13:25:21 morfikownia kernel: [ 23.785610] iptables_INPUT_denied: IN=eth0 OUT= MAC= SRC=192.168.0.182 DST=224.0.0.251 LEN=221 TOS=0x00 PREC=0x00 TTL=255 ID=8704 DF PROTO=UDP SPT=5353 DPT=5353 LEN=201 May 15 13:25:21 morfikownia kernel: [ 23.898240] iptables_INPUT_denied: IN=virbr1 OUT= MAC= SRC=192.168.100.1 DST=224.0.0.251 LEN=73 TOS=0x00 PREC=0x00 TTL=255 ID=48398 DF PROTO=UDP SPT=5353 DPT=5353 LEN=53 May 15 13:25:21 morfikownia kernel: [ 23.938236] iptables_INPUT_denied: IN=virbr1 OUT= MAC= SRC=192.168.100.1 DST=224.0.0.251 LEN=239 TOS=0x00 PREC=0x00 TTL=255 ID=48407 DF PROTO=UDP SPT=5353 DPT=5353 LEN=219 May 15 13:25:35 morfikownia kernel: [ 38.048388] iptables_INPUT_denied: IN=eth0 OUT= MAC= SRC=192.168.0.182 DST=224.0.0.251 LEN=73 TOS=0x00 PREC=0x00 TTL=255 ID=18271 DF PROTO=UDP SPT=5353 DPT=5353 LEN=53 May 15 13:25:45 morfikownia kernel: [ 47.660872] iptables_INPUT_denied: IN=eth0 OUT= MAC= SRC=192.168.0.182 DST=192.168.0.255 LEN=44 TOS=0x00 PREC=0x00 TTL=64 ID=52758 DF PROTO=UDP SPT=8612 DPT=8612 LEN=24 May 15 13:26:07 morfikownia kernel: [ 69.596831] iptables_INPUT_denied: IN=eth0 OUT= MAC=60:a4:4c:64:a8:bd:00:0b:00:00:ad:d0:08:00 SRC=192.168.0.1 DST=192.168.0.182 LEN=80 TOS=0x00 PREC=0x00 TTL=64 ID=35827 PROTO=UDP SPT=53 DPT=52338 LEN=60 May 15 13:26:09 morfikownia kernel: [ 72.323993] iptables_INPUT_denied: IN=eth0 OUT= MAC=60:a4:4c:64:a8:bd:00:0b:00:00:ad:d0:08:00 SRC=192.168.0.1 DST=192.168.0.182 LEN=78 TOS=0x00 PREC=0x00 TTL=64 ID=35829 PROTO=UDP SPT=53 DPT=65378 LEN=58 May 15 13:26:23 morfikownia kernel: [ 86.058906] iptables_INPUT_denied: IN=eth0 OUT= MAC= SRC=192.168.0.182 DST=224.0.0.251 LEN=73 TOS=0x00 PREC=0x00 TTL=255 ID=29553 DF PROTO=UDP SPT=5353 DPT=5353 LEN=53 May 15 13:26:40 morfikownia kernel: [ 102.774789] iptables_INPUT_denied: IN=eth0 OUT= MAC=60:a4:4c:64:a8:bd:00:0b:00:00:ad:d0:08:00 SRC=209.85.202.100 DST=192.168.0.182 LEN=52 TOS=0x00 PREC=0x00 TTL=49 ID=50782 PROTO=TCP SPT=80 DPT=64706 WINDOW=343 RES=0x00 ACK URGP=0 May 15 13:26:50 morfikownia kernel: [ 112.820618] iptables_INPUT_denied: IN=eth0 OUT= MAC=60:a4:4c:64:a8:bd:00:0b:00:00:ad:d0:08:00 SRC=209.85.202.100 DST=192.168.0.182 LEN=52 TOS=0x00 PREC=0x00 TTL=49 ID=54479 PROTO=TCP SPT=80 DPT=64706 WINDOW=343 RES=0x00 ACK URGP=0 May 15 13:26:57 morfikownia kernel: [ 119.690472] iptables_INPUT_denied: IN=eth0 OUT= MAC=01:00:5e:00:00:fb:bc:cf:cc:56:45:a6:08:00 SRC=192.168.0.32 DST=224.0.0.251 LEN=73 TOS=0x00 PREC=0x00 TTL=1 ID=29918 DF PROTO=UDP SPT=55225 DPT=5353 LEN=53 May 15 13:27:10 morfikownia kernel: [ 132.554127] iptables_INPUT_denied: IN=eth0 OUT= MAC=60:a4:4c:64:a8:bd:00:0b:00:00:ad:d0:08:00 SRC=209.85.202.138 DST=192.168.0.182 LEN=52 TOS=0x00 PREC=0x00 TTL=49 ID=49086 PROTO=TCP SPT=443 DPT=53198 WINDOW=377 RES=0x00 ACK URGP=0 May 15 13:27:27 morfikownia kernel: [ 150.125088] iptables_INPUT_denied: IN=eth0 OUT= MAC= SRC=192.168.0.182 DST=224.0.0.251 LEN=73 TOS=0x00 PREC=0x00 TTL=255 ID=19623 DF PROTO=UDP SPT=5353 DPT=5353 LEN=53 May 15 13:27:40 morfikownia kernel: [ 162.938242] iptables_INPUT_denied: IN=eth0 OUT= MAC=60:a4:4c:64:a8:bd:00:0b:00:00:ad:d0:08:00 SRC=209.85.202.100 DST=192.168.0.182 LEN=52 TOS=0x00 PREC=0x00 TTL=49 ID=14448 PROTO=TCP SPT=80 DPT=64706 WINDOW=343 RES=0x00 ACK URGP=0 May 15 13:27:45 morfikownia kernel: [ 168.368979] iptables_INPUT_denied: IN=eth0 OUT= MAC=01:00:5e:00:00:fb:bc:cf:cc:56:45:a6:08:00 SRC=192.168.0.32 DST=224.0.0.251 LEN=73 TOS=0x00 PREC=0x00 TTL=1 ID=29921 DF PROTO=UDP SPT=55225 DPT=5353 LEN=53 May 15 13:28:00 morfikownia kernel: [ 183.042294] iptables_INPUT_denied: IN=eth0 OUT= MAC=60:a4:4c:64:a8:bd:00:0b:00:00:ad:d0:08:00 SRC=209.85.202.100 DST=192.168.0.182 LEN=52 TOS=0x00 PREC=0x00 TTL=49 ID=25148 PROTO=TCP SPT=80 DPT=64706 WINDOW=343 RES=0x00 ACK URGP=0
Tak jest dla jednego prefixa, a jak zrobic zeby zeby kazdego z 5 roznych prefksow zapisywalo oddzielnie, oczywiscie w tym samym pliku?
Offline
Kiedys dawno temu podales mi linka do twojego pliku konfiguracyjnegp sysctl.conf
https://forum.dug.net.pl/viewtopic.php?id=25863&p=2
Moja domyslna interpretacja: : if $msg contains 'iptables_INPUT_denied:' then -/var/log/firewall ?
- jezeli wiadomosc zawiera 'iptables_INPUT_denied:' to zapisz ja do pliku firewall " then -/var/log/firewall "
Tylko moja dedukcja, wiec bez gwarancji (:-(
Dla 5 prefiksow moglbym zrobic 5 plikow i pewnie by gralo.
Tak jest dla jednego prefixa, a jak zrobic zeby zeby dla kazdego z 5 roznych prefksow zapisywalo oddzielnie, oczywiscie w tym samym pliku?
Ostatnio edytowany przez Novi-cjusz (2016-05-15 18:32:16)
Offline
No to wiesz co znaczy zapis i nie wiesz jak dopasować 5 prefixów? Podpowiedź, może inne dopasowanie, może te prefixy zawierają część wspólną? xD
BTW: jak zamierzasz tylko kopiować (tak jak ten sysctl), to daleko nie zajedziesz. Jak skopiowałeś cały mój plik via ctrl+c i ctrl+v, to pewnie coś sobie w konfiguracji rozwaliłeś albo też bezpieczeństwo systemu ci ucierpiało. Ja ci radzę przeczytać ten plik zanim cokolwiek z niego skopiujesz, bo on jest dopasowany do mojego systemu, a mój system jest.... mój. xD Morfikownia może być tylko jedna. xD
Ostatnio edytowany przez morfik (2016-05-15 20:29:38)
Offline
@morfik
W sprawie kopiowania pliku sysctl.conf to masz w 100% racje, ja myslalem, ze odptaszkowales tylko uniwersalne ustawienia a indywidualne zaptaszkowales. Zeby ten plik przemyslec to trzeba tygodnia czasu.
Moze w weekend sie za to wezme i wywale co niepotrzebne.
Post dotarl do pomyslnego ( SOLVED ) zakonczenia dzieki zyczliwemu wsparciu profesionalistow na DUG-u, a szczegolnie "morfikowi" Dziekuje.
Offline
Strony: 1
Time (s) | Query |
---|---|
0.00014 | SET CHARSET latin2 |
0.00005 | SET NAMES latin2 |
0.00194 | SELECT u.*, g.*, o.logged FROM punbb_users AS u INNER JOIN punbb_groups AS g ON u.group_id=g.g_id LEFT JOIN punbb_online AS o ON o.ident='3.137.164.43' WHERE u.id=1 |
0.00091 | REPLACE INTO punbb_online (user_id, ident, logged) VALUES(1, '3.137.164.43', 1731780833) |
0.00082 | SELECT * FROM punbb_online WHERE logged<1731780533 |
0.00113 | DELETE FROM punbb_online WHERE ident='185.191.171.3' |
0.00126 | DELETE FROM punbb_online WHERE ident='3.224.104.67' |
0.00079 | SELECT topic_id FROM punbb_posts WHERE id=301548 |
0.00205 | SELECT id FROM punbb_posts WHERE topic_id=28617 ORDER BY posted |
0.00090 | SELECT t.subject, t.closed, t.num_replies, t.sticky, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, 0 FROM punbb_topics AS t INNER JOIN punbb_forums AS f ON f.id=t.forum_id LEFT JOIN punbb_forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id=28617 AND t.moved_to IS NULL |
0.00009 | SELECT search_for, replace_with FROM punbb_censoring |
0.00197 | SELECT u.email, u.title, u.url, u.location, u.use_avatar, u.signature, u.email_setting, u.num_posts, u.registered, u.admin_note, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, g.g_id, g.g_user_title, o.user_id AS is_online FROM punbb_posts AS p INNER JOIN punbb_users AS u ON u.id=p.poster_id INNER JOIN punbb_groups AS g ON g.g_id=u.group_id LEFT JOIN punbb_online AS o ON (o.user_id=u.id AND o.user_id!=1 AND o.idle=0) WHERE p.topic_id=28617 ORDER BY p.id LIMIT 0,25 |
0.00139 | UPDATE punbb_topics SET num_views=num_views+1 WHERE id=28617 |
Total query time: 0.01344 s |