在 centos 7 上记录 iptables 事件

deb*_*bek 3 logs iptables centos dmesg

我的 centos 7 上有 iptables。我的防火墙被禁用。如何记录我的 iptables 事件?在 debian 上它是 dmesg 选项,但我不知道如何在 centos 上设置它。

我想记录所有 iptables 事件。没有具体规定。

tel*_*coM 6

当数据包与iptables ... -j LOG规则匹配时,会生成内核日志消息。您可以使用 选项指定消息的严重性级别--log-level <level>,其中<level>可以是标准系统日志级别标识符之一:emergalertcriterrorwarningnoticeinfodebug

这些日志消息的处理方式是rsyslog:如果严重级别足够低,rsyslog可能会完全丢弃这些消息。由于 iptables 日志消息来自内核,因此它们的日志记录类别将始终为kern. 因此,请查看要处理的消息的/etc/rsyslog.conf最低严重性级别是什么,以及它们将存储到哪个日志文件中。kern.*然后为您的规则设置适当的严重性级别iptables -j LOG

或者使用该iptables ... -j LOG --log-prefix <prefix>选项向 iptables 消息添加可识别的前缀,然后使用 的高级功能rsyslog将 iptables 消息写入单独的日志文件。