13.6. 系统引导时自动载入 nftables 规则
nftables systemd 服务加载包含在 /etc/sysconfig/nftables.conf 文件中的防火墙脚本。
先决条件
-
nftables脚本存储在/etc/nftables/目录中。
流程
编辑
/etc/sysconfig/nftables.conf文件。-
如果您使用
nftables软件包的安装修改了在/etc/nftables/中创建的*.nft脚本,请取消对这些脚本的include语句的注释。 如果您编写了新脚本,请添加
include语句以包含这些脚本。例如,要在nftables服务启动时加载/etc/nftables/example.nft脚本,请添加:include "/etc/nftables/example.nft"
include "/etc/nftables/example.nft"Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
如果您使用
可选:启动
nftables服务来加载防火墙规则,而无需重启系统:systemctl start nftables
# systemctl start nftablesCopy to Clipboard Copied! Toggle word wrap Toggle overflow 启用
nftables服务。systemctl enable nftables
# systemctl enable nftablesCopy to Clipboard Copied! Toggle word wrap Toggle overflow