我经常使用iptables进行日志记录,为了将我的日志放在一个单独的文件中,我在/etc/rsyslog.d/iptables.conf中放置了一些规则
:msg, startswith, "iptables: " -/var/log/iptables.log
& ~
:msg, regex, "^\[ *[0-9]*\.[0-9]*\] iptables: " -/var/log/iptables.log
& ~发布于 2017-05-01 02:23:42
问题是,当在iptables中使用日志作为目标时,即使从kern.log等删除了rsyslog,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"https://stackoverflow.com/questions/43705635
复制相似问题