SagerNet / sing-box

The universal proxy platform
https://sing-box.sagernet.org/
Other
15.38k stars 1.89k forks source link

官网Traffic bypass示例不起作用 #1830

Closed bh7825 closed 3 weeks ago

bh7825 commented 3 weeks ago

官网有个Traffic bypass usage for Chinese users之《Without DNS leaks, but slower (1.9.0-alpha.2+)》客户端配置文件,代码如下: https://sing-box.sagernet.org/manual/proxy/client/#traffic-bypass-usage-for-chinese-users

{
  "dns": {
    "servers": [
      {
        "tag": "google",
        "address": "tls://8.8.8.8"
      },
      {
        "tag": "local",
        "address": "https://223.5.5.5/dns-query",
        "detour": "direct"
      }
    ],
    "rules": [
      {
        "outbound": "any",
        "server": "local"
      },
      {
        "clash_mode": "Direct",
        "server": "local"
      },
      {
        "clash_mode": "Global",
        "server": "google"
      },
      {
        "rule_set": "geosite-geolocation-cn",
        "server": "local"
      },
      {
        "type": "logical",
        "mode": "and",
        "rules": [
          {
            "rule_set": "geosite-geolocation-!cn",
            "invert": true
          },
          {
            "rule_set": "geoip-cn"
          }
        ],
        "server": "google",
        "client_subnet": "114.114.114.114/24" // Any China client IP address
      }
    ]
  },
  "route": {
    "rule_set": [
      {
        "type": "remote",
        "tag": "geosite-geolocation-cn",
        "format": "binary",
        "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-cn.srs"
      },
      {
        "type": "remote",
        "tag": "geosite-geolocation-!cn",
        "format": "binary",
        "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-!cn.srs"
      },
      {
        "type": "remote",
        "tag": "geoip-cn",
        "format": "binary",
        "url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs"
      }
    ]
  },
  "experimental": {
    "cache_file": {
      "enabled": true,
      "store_rdrc": true
    },
    "clash_api": {
      "default_mode": "Enhanced"
    }
  }
}

上面文件包含dns和route部分,没有inbount和outbound部分,根据官网描述,客户端需要增加outbound,至于inbound,客户端好像不需要。所以,我把官网Shadowsocks协议的Client Example添加到上面代码中: https://sing-box.sagernet.org/manual/proxy-protocol/shadowsocks/#client-example

{
  "outbounds": [
    {
      "type": "shadowsocks",
      "server": "127.0.0.1",
      "server_port": 8080,
      "method": "2022-blake3-aes-128-gcm",
      "password": "<pasword>",
      "multiplex": {
        "enabled": true
      }
    }
  ]
}

然后填写server的ip地址和密码,然后执行下面两个命令检查配置文件,均没有显示错误:

sing-box check -c config.json
sing-box format -w -c config.json

然后运行脚本,显示如下信息:

PS D:\fanqiang\sing-box-1.9.0-windows-amd64> .\sing-box.exe run -c config.json
INFO[0000] router: updated default interface WLAN, index 7
INFO[0000] sing-box started (0.44s)

然后,在chrome中测试访问google和youyube等,均不能访问。 请问应该怎么修改客户端配置文件?

至于服务端配置文件,我用的默认配置文件,填写了自己的密码:


{
  "log": {
    "level": "info"
  },
  "dns": {
    "servers": [
      {
        "address": "tls://8.8.8.8"
      }
    ]
  },
  "inbounds": [
    {
      "type": "shadowsocks",
      "listen": "::",
      "listen_port": 8080,
      "sniff": true,
      "network": "tcp",
      "method": "2022-blake3-aes-128-gcm",
      "password": "<password>",
      "multiplex": {
        "enabled": true
      }
    }
  ],
  "outbounds": [
    {
      "type": "direct"
    },
    {
      "type": "dns",
      "tag": "dns-out"
    }
  ],
  "route": {
    "rules": [
      {
        "protocol": "dns",
        "outbound": "dns-out"
      }
    ]
  }
}

服务端配置文件已检查,已经正常运行: Snipaste_2024-06-04_14-02-07