Red Hat Training
A Red Hat training course is available for RHEL 8
47.10.2. 在现有规则中添加计数器
在识别规则是否匹配时,可以使用计数器。
- 有关添加带有计数器的新规则的流程的更多信息,请参阅 创建带有计数器的规则 。
前提条件
- 您要添加计数器的规则已存在。
流程
在链中显示规则及其句柄:
# nft --handle list chain inet example_table example_chain table inet example_table { chain example_chain { # handle 1 type filter hook input priority filter; policy accept; tcp dport ssh accept # handle 4 } }
通过使用
counter
参数替换规则来添加计数器。以下示例替换了上一步中显示的规则并添加计数器:# nft replace rule inet example_table example_chain handle 4 tcp dport 22 counter accept
显示计数器值:
# nft list ruleset table inet example_table { chain example_chain { type filter hook input priority filter; policy accept; tcp dport ssh counter packets 6872 bytes 105448565 accept } }