
iptables에서 생성된 로그 메시지를 rsyslogd를 통해 다른 파일에 저장하고 싶습니다.
현재 다음 코드를 사용합니다 /etc/rsyslog.d/20-custom.conf
.
# Log cron to cron.log and not to syslog
*.*;cron,auth,authpriv.none -/var/log/syslog
cron.* /var/log/cron.log
# Log firewall to extra log
:msg,contains,"[BLOCK " /var/log/firewall.log
& stop
내 cron 로그는 괜찮습니다. 에만 기록되지만 cron.log
iptables 로그는 syslog
및 firewall.log
. 로그인만 할 수 있는 방법이 있나요 firewall.log
?
내 시스템 사양:
> rsyslogd -v
rsyslogd 8.16.0, compiled with:
PLATFORM: x86_64-pc-linux-gnu
PLATFORM (lsb_release -d):
FEATURE_REGEXP: Yes
GSSAPI Kerberos 5 support: Yes
FEATURE_DEBUG (debug build, slow code): No
32bit Atomic operations supported: Yes
64bit Atomic operations supported: Yes
memory allocator: system default
Runtime Instrumentation (slow code): No
uuid support: Yes
Number of Bits in RainerScript integers: 64
Linux MYHOSTNAME 4.4.0-116-generic #140-Ubuntu SMP Mon Feb 12 21:23:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.4 LTS
Release: 16.04
Codename: xenial
답변1
방화벽 로깅 부분을 다른 규칙보다 먼저 이동해야 다음과 같이 보입니다.
# Log firewall to extra log
:msg,contains,"[BLOCK " /var/log/firewall.log
& stop
# Log cron to cron.log and not to syslog
*.*;cron,auth,authpriv.none -/var/log/syslog
cron.* /var/log/cron.log
규칙은 순서대로 고려되므로 이제 일치하는 메시지가 표시됩니다.*.*;cron,auth,authpriv.none일치하더라도 항상 syslog에 기록됩니다.:msg,포함,"[BLOCK "그리고 Firewall.log에 기록됩니다. 중지 명령은 파일에서 아무것도 중지하기에는 너무 늦었습니다.
또한보십시오https://www.rsyslog.com/writing-특이적-messages-to-a-file-and-discarding-them/