routerOS 容器内安装 sing-box,使用的 Tun 模式, route 字段没搞懂匹配规则,咨询下大家

23 天前
 isAK47

配置规则如下,目前国外列表使用 fakeip 可以正常访问,国内没有添加列表,但是网站、APP 都正常访问,目前看国内都是直连,可是 final 明明使用了代理,这一点理解不了。

{
  "log": {
    "disabled": false,
    "level": "error",
    "timestamp": true
  },
  "dns": {
    "servers": [
      {
        "tag": "dns_local",
        "address": "114.114.114.114",
        "detour": "direct"
      },
      {
        "tag": "dns_proxy",
        "address": "https://8.8.8.8/dns-query",
        "address_resolver": "dns_local",
        "detour": "proxy"
      },
      {
        "tag": "dns_fakeip",
        "address": "fakeip"
      }
    ],
    "rules": [
      {
        "outbound": "any",
        "server": "dns_local",
        "disable_cache": true
      },
      {
        "rule_set": "geolocation-!cn",
        "server": "dns_fakeip"
      }
    ],
    "strategy": "ipv4_only",
    "fakeip": {
      "enabled": true,
      "inet4_range": "198.18.0.0/16"
    }
  },
  "route": {
    "rule_set": [
      {
        "tag": "geosite-geolocation-!cn",
        "type": "remote",
        "format": "binary",
        "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-!cn.srs",
        "download_detour": "direct"
      }
    ],
    "rules": [
      {
        "inbound": "dns-in",
        "outbound": "dns-out"
      },
      {
        "protocol": "dns",
        "outbound": "dns-out"
      },
      {
        "port": 53,
        "outbound": "dns-out"
      },
      {
        "ip_is_private": true,
        "outbound": "direct"
      }
    ],
    "final": "proxy",
    "default_interface": "ether0"
  },
  "inbounds": [
    {
      "type": "direct",
      "tag": "dns-in",
      "listen": "0.0.0.0",
      "listen_port": 53
    },
    {
      "type": "tun",
      "tag": "tun-in",
      "inet4_address": "198.18.0.0/16",
      "strict_route": true,
      "stack": "system",
      "sniff": true,
      "sniff_override_destination": true
    }
  ],
  "outbounds": [
    {
      "type": "direct",
      "tag": "direct"
    },
    {
      "type": "block",
      "tag": "block"
    },
    {
      "type": "dns",
      "tag": "dns-out"
    },
    {
       "tag": "proxy",
       "type": "vless",
       "flow": "",
       "server": "",
       "server_port": 443 ,
       "uuid": ""
    }
  ]
}
1176 次点击
所在节点    宽带症候群
8 条回复
wan89883
23 天前
可能和你的策略路由配置有关,国内域名返回的是真 IP ,路由器直接走默认网关,没进入 singbox
isAK47
23 天前
@wan89883 看日志是进入 singbox 了,不过 router 节点日志只匹配了 dns 解析( router: match[0] inbound=dns-in => dns-out ),router 里面也加入了 geosite-cn 、geoip-cn 等规则,日志里面看都没匹配到。
wan89883
23 天前
@isAK47 dns 是通过 dns-in 进入 singbox 的,但是当程序拿到 dns 解析结果,通过目的 IP 开始 tcp 握手时,这个 IP 由于不属于 198.18.0.0/16 ,tcp 握手请求就直接被路由器发送到正常网关了,没进入 tun 。具体什么问题得根据你 routeros 的策略路由配置来确定。
isAK47
22 天前
@wan89883 路由器基本是默认的,分流全部在配置文件中。目前只在/ip route 中把 198.18.0.0/16 网关设置为容器 IP ,并且走的主路由表;如果要让国内列表也走 sing-box ,策略路由该怎么修改呢,对这块了解的比较浅,还望大佬指点一下,谢谢了!
wan89883
22 天前
@isAK47 在 singbox 的 config 里面配置 dns 的 final 规则为 fakeip 就可以了。
isAK47
22 天前
@wan89883 dns.final 不允许设置为 fakeip 的
wan89883
22 天前
@isAK47 那就加一条 dns 规则,
{
"query_type": [
"А",
"AAAA"
],
"server": "dns_fakeip"
}
isAK47
22 天前
@wan89883 #7 这个对域名是可以的,如果是国内 IP 列表会被忽略,看样子还是要对路由器做策略

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1067788

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX