跳转到内容
搜索 RunEntLinux 文档

仅搜索 RunEntLinux 通用文档,各发行版文档使用各自的搜索入口。

    浏览当前文档目录

    EL 8:nftables 取代 iptables

    EL 8 把防火墙栈的默认后端从 iptables 切换为 nftables:firewalld 生成的规则落到 nftables 内核框架,iptables 等命令则通过 nft 兼容层继续可用。这是 EL 网络栈现代化的关键一步,也为后续更复杂的流表与性能优化铺路。

    nftables 是 iptables/ip6tables/arptables/ebtables 的统一继任者:单一内核框架、单一用户态工具 nft,规则以表达式语法描述,支持原子批量更新(不再有”改一半规则”的窗口),性能与可维护性更好。

    EL 8 的切换方式是”后端替换 + 前端兼容”:

    • firewalld 的配置项 FirewallBackend=nftables(/etc/firewalld/firewalld.conf)成为默认;
    • iptables / ip6tables / arptables / ebtables 命令变为 nft 的兼容前端,看到的规则是 nft 规则的翻译视图;
    • 直接使用 iptables 内核 API 的程序(部分老容器网络插件、安全 agent)需要适配。
    项EL 7EL 8
    firewalld 后端iptablesnftables(默认)
    规则查看iptables -Lnft list ruleset(兼容命令仍可用)
    批处理更新逐条原子
    框架数量iptables/ip6tables/arptables/ebtables统一 nftables
    • 用 firewalld 的管理流程:firewall-cmd 语法不变,几乎无感。
    • 手写 iptables 规则/脚本:iptables-save 输出格式与语义细节有差异;把规则翻译进 firewalld 或改写为 nft 语法更稳妥。
    • 第三方网络组件:老版本容器网络插件、入侵检测/流量镜像 agent 若直接操作 iptables 内核表,需升级到支持 nftables 的版本。
    • 排障习惯:看规则请用 nft list ruleset,兼容命令的视图可能与实际表结构不一致。
    查看当前后端与规则集
    grep FirewallBackend /etc/firewalld/firewalld.conf
    sudo nft list ruleset | head -30
    1. 盘点现网手写 iptables 规则与依赖 iptables 的组件版本;
    2. 规则迁入 firewalld(zone/service/rich rule)或改写为 nft 脚本;
    3. 升级第三方组件到声明支持 nftables 的版本。