V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
shangnengfanfo
V2EX  ›  宽带症候群

关于 sing-box 的规则问题咨询下大家, dns 和 route 规则为什么不同步?

  •  
  •   shangnengfanfo · 102 天前 · 1827 次点击
    这是一个创建于 102 天前的主题,其中的信息可能已经有所发展或是发生改变。

    国内小众站都走代理了,看日志 dns 模块是触发 geoip-cn 这条规则了,但是 route 模块直接走 final ,好奇为什么不会经过 route 内的 geoip-cn 规则走直连呢?

      头部省略。。。
     "dns": {
        "servers": [
          {"tag": "dns_local", "address": "223.5.5.5", "detour": "direct", "strategy": "ipv4_only"},
          {"tag": "dns_proxy", "address": "https://8.8.8.8/dns-query", "address_resolver": "dns_local", "detour": "proxy", "strategy": "ipv4_only"},
          {"tag": "dns_fakeip", "address": "fakeip"}
        ],
        "rules": [
          {"outbound": "any", "server": "dns_local"},
          {"rule_set": "geosite-geolocation-!cn", "server": "dns_fakeip"},
          {"rule_set": ["geosite-geolocation-cn", "geoip-cn"], "server": "dns_local"}
        ],
        "disable_cache": true,
        "fakeip": {
          "enabled": true,
          "inet4_range": "172.7.0.0/15",
          "inet6_range": "fc00:172:7::/126"
        }
      },
      "route": {
        "rules": [
          {"inbound": "dns-in", "outbound": "dns-out"},
          {"protocol": "dns", "outbound": "dns-out"},
          {"ip_is_private": true, "outbound": "direct"},
          {"rule_set": "geosite-geolocation-!cn", "outbound": "proxy"},
          {"rule_set": ["geosite-geolocation-cn", "geoip-cn"], "outbound": "direct"},
          {"inbound": "mixed-in", "outbound": "proxy"}
        ],
        "rule_set": [
        此处省略。。。
        ],
        "final": "proxy",
        "auto_detect_interface": true
      },
      "inbounds": [
        {
          "type": "tun",
          "tag": "tun-in",
          "inet4_address": "172.7.0.1/30",
          "inet6_address": "fd00:172:7::1/126",
          "mtu": 1400,
          "auto_route": true,
          "strict_route": true,
          "stack": "system",
          "sniff": true,
          "sniff_override_destination": true,
          "gso": false
        },
        {
          "type": "mixed",
          "tag": "mixed-in",
          "listen": "0.0.0.0",
          "listen_port": 7890
        }
      ],
      尾部省略。。。
    
    8 条回复    2024-09-15 10:55:25 +08:00
    yellowvii
        1
    yellowvii  
       101 天前
    域名请求不会进行 IP 匹配
    yellowvii
        2
    yellowvii  
       101 天前
    @yellowvii #1

    这个行为可以通过配置改变

    延伸阅读: https://sing-box.sagernet.org/configuration/shared/listen/#domain_strategy

    domain_strategy

    One of prefer_ipv4 prefer_ipv6 ipv4_only ipv6_only.

    If set, the requested domain name will be resolved to IP before routing.

    If sniff_override_destination is in effect, its value will be taken as a fallback.
    shangnengfanfo
        3
    shangnengfanfo  
    OP
       101 天前
    @yellowvii 前一句很好理解,后面这句没怎么懂——如果 sniff_override_destination 生效,它的值将作为后备。
    yellowvii
        4
    yellowvii  
       101 天前
    @shangnengfanfo #3 我理解同时配置两者,sniff_override_destination 的优先级高
    shangnengfanfo
        5
    shangnengfanfo  
    OP
       101 天前
    @yellowvii 已经用上了,目前运行良好,非常感谢!!!
    singbox 是好东西,就是它的文档一言难尽
    belldasd
        6
    belldasd  
       98 天前
    @shangnengfanfo 请问具体怎么修改配置?
    shangnengfanfo
        7
    shangnengfanfo  
    OP
       98 天前 via Android
    @belldasd "domain_strategy": "prefer_ipv4", 把这个加进去就可以了
    belldasd
        8
    belldasd  
       98 天前
    @shangnengfanfo 谢谢!我去试试看。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2747 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 09:28 · PVG 17:28 · LAX 01:28 · JFK 04:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.