第 20 章 使用 flowtables 加快 nftables 数据包转发


nftables 工具使用 Netfilter 框架,它提供基于快速路径功能的 流化 机制来加快已建立连接的数据包。

flowtable 机制有以下功能:

  • 使用连接跟踪来绕过典型的数据包转发路径。
  • 避免通过绕过经典数据包处理来重新访问路由表。
  • 只适用于 TCP 和 UDP 协议。
  • 硬件独立软件快速路径。

流程

  1. 添加 inet 系列的一个 example-table

    # nft add table inet <example-table>
    Copy to Clipboard
  2. 添加一个带有 ingress 钩子和 filter 作为优先级类型的 example-flowtable flowtable :

    # nft add flowtable inet <example-table> <example-flowtable> { hook ingress priority filter \; devices = { example_device_one, example_device_two } \; }
    Copy to Clipboard
  3. example-forwardchain 流添加到数据包处理表中的 flowtable :

    # nft add chain inet <example-table> <example-forwardchain> { type filter hook forward priority filter \; }
    Copy to Clipboard

    此命令添加了一个带有 forward 钩子和 filter 优先级的 filter 类型的 flowtable 。

  4. 添加一个 established 连接跟踪状态的规则,来卸载 example-flowtable 流:

    # nft add rule inet <example-table> <example-forwardchain> ct state { established, related } flow add @<example-flowtable>
    Copy to Clipboard

验证

  • 验证 example-table 的属性:

    # nft list table inet <example-table>
    table inet example-table {
          flowtable example-flowtable {
            hook ingress priority filter
               devices = { example_device_one, example_device_two }
          }
    
          chain example-forwardchain {
    type filter hook forward priority filter; policy accept;
    ct state established flow add @example-flowtable
        }
    }
    Copy to Clipboard
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat