V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
cxxnullptr
V2EX  ›  程序员

nftables 学得有点懵

  •  
  •   cxxnullptr · 1 天前 · 1044 次点击

    多个相同 hook ,一个 accept ,后面的还执行吗?

    chatgpt 和 grok 说 accept 就终结了,gemini 说还能继续执行

    chatgpt 回答

    grok 回答

    gemini 回答

    规则 1 ,不同优先级

    table inet A {
      chain input {
        type filter hook input priority 0;
        tcp dport 22 accept
      }
    }
    
    
    table inet B {
      chain input {
        type filter hook input priority 10;
        tcp dport 22 drop
      }
    } 
    

    规则 2 ,相同优先级

    table inet A {
      chain input {
        type filter hook input priority 0;
        tcp dport 22 accept
      }
    }
    
    
    table inet B {
      chain input {
        type filter hook input priority 0;
        tcp dport 22 drop
      }
    }
    
    8 条回复    2026-02-08 09:16:10 +08:00
    slowman
        1
    slowman  
       1 天前
    nftables 文档怎么说
    KagurazakaNyaa
        2
    KagurazakaNyaa  
       1 天前
    EchoWhale
        3
    EchoWhale  
       1 天前 via iPhone
    不再执行当前 chain 的其他规则,但会执行其他 chain 的规则。

    NOTE: If a packet is accepted and there is another chain, bearing the same hook type and with a later priority, then the packet will subsequently traverse this other chain. Hence, an accept verdict - be it by way of a rule or the default chain policy - isn't necessarily final. However, the same is not true of packets that are subjected to a drop verdict. Instead, drops take immediate effect, with no further rules or chains being evaluated.

    https://wiki.nftables.org/wiki-nftables/index.php/Configuring_chains
    june4
        4
    june4  
       1 天前
    以前学 nft 对这个语法是真恶心,一串中间没有任何符合分隔,鬼才的发明
    cxxnullptr
        5
    cxxnullptr  
    OP
       1 天前
    @KagurazakaNyaa @EchoWhale

    感谢两位,是不是 gemini 的回答是对的
    cxxnullptr
        6
    cxxnullptr  
    OP
       1 天前
    @june4 确实,docker 还给生成的一大坨,看得发懵
    pagxir
        7
    pagxir  
       21 小时 15 分钟前 via Android
    @june4 很是赞同,从来就没有过这么难用的 cli 了
    yougg
        8
    yougg  
       10 小时 34 分钟前
    加上 counter 发个请求看看就知道了
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   1926 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 11:50 · PVG 19:50 · LAX 03:50 · JFK 06:50
    ♥ Do have faith in what you're doing.