比如我有两个表:
table inet filter2 {
chain forward {
type filter hook forward priority 0; policy accept;
ct state established,related accept
iifname $wireif oifname $wirelessif accept
}
}
table inet filter {
chain forward {
type filter hook forward priority 0; policy accept;
drop
}
}
filter
首先执行,所以我所有的转发数据包都被丢弃,这不是我想要的。如何设置最后执行的表/链使其作为默认选项?
最佳答案
Nftables 使用底层 netfilter 框架 has 6 hooks points位于 linux 内核网络堆栈的不同位置。
当一个或多个规则被添加到同一个 Hook 点时,netfilter 框架按照规则的 priority type 对规则进行优先级排序。 .
例如,在您添加链的情况下,您可以为每个链使用不同的优先级类型。
比方说你想给予规则定义的 forward chain
of
filter table
比 filter2 table
的 forward chain
.
nft add table ip filter2
nft add chain ip filter2 forward {type filter hook forward priority 0 \;}
现在给 filter
表的 forward chain
赋予更高的优先级,分配优先级小于 0。
nft add table inet filter
nft add chain inet filter '{type filter hook forward priority -1 }'
这里较高的优先级值意味着较低的优先级,反之亦然。
但是在使用不同的优先级类型时要小心,因为它有时可能会导致数据包出现意外行为。更多信息请阅读 this
关于linux - nftables中表/链的顺序是怎么排列的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38162173/