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

nftables 学得有点懵

  •  
  •   cxxnullptr · 12 小时 5 分钟前 · 744 次点击

    多个相同 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
      }
    }
    
    7 条回复    2026-02-07 22:34:49 +08:00
    slowman
        1
    slowman  
       12 小时 1 分钟前
    nftables 文档怎么说
    KagurazakaNyaa
        2
    KagurazakaNyaa  
       12 小时 1 分钟前
    EchoWhale
        3
    EchoWhale  
       11 小时 54 分钟前 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  
       11 小时 53 分钟前
    以前学 nft 对这个语法是真恶心,一串中间没有任何符合分隔,鬼才的发明
    cxxnullptr
        5
    cxxnullptr  
    OP
       11 小时 41 分钟前
    @KagurazakaNyaa @EchoWhale

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