mau*_*cev 6 linux-networking nftables
我有一个在输入链中丢弃数据包的策略
chain input {
type filter hook input priority 0; policy drop;
Run Code Online (Sandbox Code Playgroud)
我怎样才能只记录这些丢弃的数据包?
好吧,我猜您还想知道 nftables 链末尾正在记录什么类型的数据包。
\n让我们假设您已经有一个日志捕获守护进程(例如syslogd、rsyslog-ng或ulogd2),该守护进程已正确配置、守护、运行并读取/dev/log由 kernel\xe2\x80\x99s 提供的所有内核日志记录(来自 )ksyslog()和将这些日志消息保存到文件(例如/var/log/message)。
如果您的链策略是accept,则将关键字附加log到您的 nftable 规则中:
\ntable filter {\n ...\n chain input {\n type filter hook input priority 0; policy accept;\n ...\n # All my rules go here\n # Pick one that suits your needs best\n\n add rule inet filter input tcp dport 22 drop log\n add rule inet filter input tcp dport 21 counter drop log prefix my_input_ftp\n\n }\n ...\n}\nRun Code Online (Sandbox Code Playgroud)\n这会将 SSH 或 FTP 的任何尝试记录到 SSH/FTP 服务器,然后丢弃数据包。
\n我会在该链的最后添加一行,filter input链的示例如下:
table filter {\n ...\n chain input {\n type filter hook input priority 0; policy drop;\n ...\n # All my rules go here\n \n ...\n # Pick one that suits your needs best\n counter comment "total unfiltered input packets"\n log # simple detail goes into the log\n log flags all # extra details go into the log\n log flags all prefix "GOTCHA!: " # parseable keyword\n log flags all counter # redundant but example\n # drop; # this is redundant policy is drop already\n }\n ...\n}\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
14022 次 |
| 最近记录: |