Hardware flowtable offload

Offloads established flows to fast path; add 'flags offload' for NIC hardware offload

nft add flowtable inet filter ft '{ hook ingress priority 0 ; devices = { eth0, eth1 } ; }' && nft add rule inet filter forward ct state established flow add @ft

tool
nftables12 commands
tags
nftablesperformancenetworkkernel

More nftables commands

  • nft add chain inet filter input '{ type filter hook input priority 0 ; policy drop ; }'

    Base-chain default-deny; note: add accept rules first or you lock yourself out

  • nft add set inet filter blocklist '{ type ipv4_addr ; flags interval ; }' && nft add element inet filter blocklist '{ 10.0.0.0/8, 192.0.2.5 }'

    Reusable named set; flags interval lets you store CIDR ranges, not just hosts

  • nft add rule inet filter input tcp dport vmap '{ 22 : accept, 80 : accept, 443 : accept, 3306 : drop }'

    vmap maps keys to verdicts in O(1); replaces a chain of dport == rules

  • nft -a list ruleset

    -a prints '# handle N' per rule; you need the handle to delete a single rule

  • nft delete rule inet filter input handle 7

    Surgical removal without flushing; get the handle from nft -a list ruleset

all 12 nftables commands