【问题标题】:journalctl shows removed iptables logsjournalctl 显示已删除的 iptables 日志
【发布时间】:2017-09-28 01:45:46
【问题描述】:

我使用 iptables 记录了很多日志并将我的日志放在一个单独的文件中,我在 /etc/rsyslog.d/iptables.conf 中放置了一些规则

:msg, startswith, "iptables: " -/var/log/iptables.log
& ~
:msg, regex, "^\[ *[0-9]*\.[0-9]*\] iptables: " -/var/log/iptables.log
& ~

这会从 /var/log/{kern.log,daemon.log,messages} 中删除日志,但是当我发出 journalctl -xe 时,所有 iptables 日志都会显示在那里 - 所以 journalctl 从哪个文件读取以及我该如何从中删除 iptables 日志?

【问题讨论】:

  • 我觉得这在 serverfault.com 或 superuser.com 上可能更合适。
  • 可以移动问题吗?还是我需要删除它并在 serverfault/superuser 处创建一个新的?

标签: logging iptables systemd rsyslog


【解决方案1】:

问题是,当在 iptables 中使用 LOG 作为目标时,即使 rsyslog 从 kern.log 等中删除,dmesg 仍会被填满。 journalctl -xe 显示此 dmesg 文本。似乎使用 ulog 是唯一的方法:

apt-get install ulogd2

在 debian 测试这个自动创建的 systemd 单元文件和配置文件。

然后我使用了 iptables 规则,例如:

iptables -N LOG_DROP
iptables -A LOG_DROP -m limit --limit 5/m --limit-burst 10 -j NFLOG --nflog-group 0 --nflog-prefix "DROP "
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --set -m comment --comment "Limit SSH IN" # add ip to recent list with --set.
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --update --seconds 60 --hitcount 10 -j LOG_DROP -m comment --comment "Limit SSH IN"

瞧,所有日志都在 /var/log/ulog/syslogemu.log 的日志文件中

【讨论】:

    猜你喜欢
    • 2016-08-11
    • 1970-01-01
    • 1970-01-01
    • 2019-03-12
    • 2018-09-24
    • 2021-10-04
    • 1970-01-01
    • 1970-01-01
    • 2019-08-24
    相关资源
    最近更新 更多