【问题标题】:What is the nft rule to let SSH tunnel to work?让 SSH 隧道工作的 nft 规则是什么?
【发布时间】:2019-04-29 09:13:50
【问题描述】:

我可以使用 nft 中的“所有 IP 都匹配”规则进行 SSH 连接:

table ip filter {
    chain INPUT {
            type filter hook input priority 0; policy drop;
            iifname "eth0" ip saddr { 0.0.0.0-255.255.255.255 } accept
    }

    chain FORWARD {
            type filter hook forward priority 0; policy accept;
    }

    chain OUTPUT {
            type filter hook output priority 0; policy accept;
    }
}

SSH 隧道在没有上述规则集的情况下工作,但在 nft 规则集出现时不起作用:

问题:在保持输入策略“丢弃”的情况下,使 SSH 隧道正常工作的最小规则是什么?

【问题讨论】:

    标签: tunnel nftables


    【解决方案1】:

    默认策略“drop”适用于所有接口。而自定义规则专门适用于“eth0”。因此,任何依赖环回接口的流量,例如 SSH 隧道,都将被默认策略阻止。

    要回答这个问题,要么删除“eth0”接口:

    ...
    chain INPUT {
            type filter hook input priority 0; policy drop;
            ip saddr { 0.0.0.0-255.255.255.255 } accept
    }
    ...
    

    或者添加loopback接口:

    ...
    chain INPUT {
            type filter hook input priority 0; policy drop;
            iifname { "lo", "eth0" } ip saddr { 0.0.0.0-255.255.255.255 } accept
    }
    ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-10-13
      • 2021-02-25
      • 1970-01-01
      • 2021-11-30
      • 1970-01-01
      • 2019-08-07
      • 2017-06-01
      相关资源
      最近更新 更多