我几乎不愿意为此提交一个主题,但我一直无法自己弄清楚。我正在运行一个Federoa 17服务器,并且我试图通过rsyslog将丢失的数据包从iptables记录到一个单独的日志文件中,但它始终将它们发送到/ var/log/messages。从我的防火墙脚本rsyslog - 基于属性的过滤不起作用
段:
#!/bin/bash
iptables -F
# My accepted rules would be here
iptables -A INPUT -j LOG --log-prefix "iptables: "
iptables -A FORWARD -j LOG --log-prefix "iptables: "
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables-save > /etc/sysconfig/iptables
service iptables restart
iptables -L -v
的配置文件应该从iptables的相扶消息:
从我rsyslog.conf文件[[email protected] ]# cat /etc/rsyslog.d/iptables.conf
:msg, startswith, "iptables: " /var/log/iptables.log
& ~
段:
#### GLOBAL DIRECTIVES ####
# Include all config files in /etc/rsyslog.d/
$IncludeConfig /etc/rsyslog.d/*.conf
#### RULES ####
# I put this in here too to see if it would work; it doesn't
:msg, startswith, "iptables: " /var/log/iptables.log
& ~
# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.* /dev/console
# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none /var/log/messages
自从进行更改后,我已经多次重启iptables和rsyslog,并且没有遮罩r什么,它只会将从iptables丢弃的数据包记录到/ var/log/messages。
我听说在兼容模式下运行rsyslog会导致各种问题。这可能是这种情况吗?下面是我的系统上其运行选项:
[[email protected] ]# ps -ef | grep rsyslog
root 3571 1 0 00:59 ? 00:00:00 /sbin/rsyslogd -n -c 5
切换到'contains'而不是'startswith'确实有效(它也没有登录到/ var/log/messages),我现在可以肯定地离开它,但是有没有办法让'开始工作,因为它应该?有没有办法在rsyslog中看看它是如何从/etc/rsyslog.conf解析其规则的? – sirjames2004
日志行形式为'Mar 31 14:36:14 localhost kernel:[6448.546951] iptables:IN = ppp0 OUT = MAC = SRC ='我认为这就是为什么'startswith'不起作用的原因。这可能会帮助你。 http://www.rsyslog.com/doc/troubleshoot.html – clement