nftables中tables/chains的顺序是怎么排列的?
How is the order of tables/chains in nftables arranged?
比如我有两个表:
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
,所以我所有的转发包都被丢弃了,这不是我想要的。如何设置最后执行的 table/chain 以使其作为默认选项使用?
Nftables 使用底层 netfilter 框架 has 6 hooks points 位于 linux 内核网络堆栈的不同位置。
当在同一个挂钩点添加一个或多个规则时,netfilter 框架按照规则的 priority type.
对规则进行优先级排序
例如,在您添加链的情况下,您可以为每个链使用不同的优先级类型。
假设您想为
的 forward chain
定义的规则赋予更高的优先级
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
table 分配小于 0 的优先级。
nft add table inet filter
nft add chain inet filter '{type filter hook forward priority -1 }'
此处较高的优先级值表示较低的优先级,反之亦然。
但是在使用不同的优先级类型时要小心,因为它有时可能会导致数据包出现意外行为。有关详细信息,请阅读 this
比如我有两个表:
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
,所以我所有的转发包都被丢弃了,这不是我想要的。如何设置最后执行的 table/chain 以使其作为默认选项使用?
Nftables 使用底层 netfilter 框架 has 6 hooks points 位于 linux 内核网络堆栈的不同位置。
当在同一个挂钩点添加一个或多个规则时,netfilter 框架按照规则的 priority type.
对规则进行优先级排序例如,在您添加链的情况下,您可以为每个链使用不同的优先级类型。 假设您想为
的forward chain
定义的规则赋予更高的优先级
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
table 分配小于 0 的优先级。
nft add table inet filter
nft add chain inet filter '{type filter hook forward priority -1 }'
此处较高的优先级值表示较低的优先级,反之亦然。
但是在使用不同的优先级类型时要小心,因为它有时可能会导致数据包出现意外行为。有关详细信息,请阅读 this