2.3.3. nftables 规则的基础知识
规则定义要在传递包含此规则的链的数据包上执行操作。如果规则还包含匹配的表达式,nftables
仅在所有之前的表达式都应用时才执行操作。
如果要在链中添加规则,要使用的格式取决于您的防火墙脚本:
在原生语法的脚本中,使用:
table <table_address_family> <table_name> { chain <chain_name> { type <type> hook <hook> priority <priority> ; policy <policy> ; <rule> } }
在 shell 脚本中,使用:
nft add rule <table_address_family> <table_name> <chain_name> <rule>
此 shell 命令在链末尾附加新规则。如果要在链开始时添加规则,请使用
nft insert
命令而不是nft add
。