首页/系统/Linux 内核与性能调优速查/nftables flowtable 快速转发
网络栈调优98 条

nftables flowtable 快速转发

转发与 NAT 场景下, flowtable 让已建立连接绕过完整协议栈路径, 以软件方式加速转发。

配置示例

配置示例
nft add table inet fast
nft 'add flowtable inet fast f { hook ingress priority 0; devices = { eth0, eth1 }; }'
nft 'add chain inet fast fwd { type filter hook forward priority 0; policy accept; }'
nft 'add rule inet fast fwd ip protocol { tcp, udp } flow add @f'
适合网关/转发角色; 仅在本文档列出的转发路径生效, 设备名与拓扑必须匹配。

易错点

  • 在终结本地流量的服务器上配置, 没有可加速的转发路径
  • 设备与 hook 写错导致规则报错或不生效

数据来源与参考

  • nftables 官方 wiki flowtable 章节
​‌‌​​‌​​​‌‌​‌‌‌‌​‌‌​​​‌‌​‌‌‌​​‌‌​​‌​‌‌‌​​‌‌‌​​​‌​‌‌​‌​​‌​‌‌‌​​​‌​‌‌​‌​​‌​‌‌​​​‌‌​‌‌‌​‌​​​‌‌​‌‌‌‌​​‌​‌‌‌​​‌‌​​​‌‌​‌‌​‌‌‌‌​‌‌​‌‌​‌