dmesgがファイアウォールログを溢れさせます。

dmesgがファイアウォールログを溢れさせます。

私のiptablesには、ドロップされたパケットを記録するルールがあります。

-A INPUT -i eth0       -j   LOG  --log-prefix "FW: " --log-level 7
-A INPUT -i eth0       -j   DROP

また、/etc/rsyslog.confこれらのログを専用ファイルに送信する別の規則があります/var/log/firewall.log

:msg, contains, "FW: "                    -/var/log/firewall.log
& ~

他のログファイルが& ~あふれたり溢れたりしないように、ログをすぐに削除してください。syslog

dmesgこれは、これらのファイアウォールログ(/var/log/dmesgコマンドの出力ではないdmesg)があふれていることを除いて、うまく機能します。

これらのログが表示されないようにする方法はありますかdmesg

ベストアンサー1

NFLOG代わりにターゲットを使用できますLOG

NFLOG
    This target provides logging of matching packets. When this  target  is  set  for  a
    rule, the Linux kernel will pass the packet to the loaded logging backend to log the
    packet. This is usually used in combination with nfnetlink_log as  logging  backend,
    which  will multicast the packet through a netlink socket to the specified multicast
    group. One or more userspace processes may subscribe to the  group  to  receive  the
    packets.  Like  LOG, this is a non-terminating target, i.e. rule traversal continues
    at the next rule.

必要なのはnfnetlink_log強力なロギングプログラムだけです。メッセージがそこに送信され、ユーザー空間プロセスがパケットを記録するかどうかを決定します。

試すもう1つの方法は、LOGルールを特定のしきい値に制限することです。

-A INPUT -i eth0 -m limit --limit 10/minutes -j LOG --log-prefix "FW: " --log-level 7
-A INPUT -i eth0 -j DROP

これは、毎分平均10個のパケットを記録します。もちろん、必要に応じて調整することもできます。

おすすめ記事