配置sing-box对接shadowsocks服务
1. 目标
客户端采用sing-box
服务器端采用shadowsocks
客户端采用tun模式
自动识别中国域名和IP
2. sing-box安装
3. sing-box配置文件
{
"dns": {
"servers": [
{
"tag": "dns_proxy",
"address": "https://1.1.1.1/dns-query",
"detour": "proxy"
},
{
"tag": "dns_resolver",
"address": "local",
"strategy": "ipv4_only",
"detour": "direct"
}
],
"rules": [
{
"rule_set": "geosite-cn",
"server": "dns_resolver"
}
],
"final": "dns_proxy",
"strategy": "ipv4_only"
},
"inbounds": [
{
"type": "tun",
"mtu": 9000,
"address": [
"172.18.0.1/30",
"fdfe:dcba:9876::1/126"
],
"auto_route": true,
"strict_route": true,
"stack": "gvisor",
"sniff": true
}
],
"outbounds": [
{
"type": "shadowsocks",
"tag": "proxy",
"server": "<shadowsocks-host>",
"server_port": <shadowsocks-port>,
"method": "<shadowsocks-method>",
"password": "<shadowsocks-password>"
},
{
"type": "direct",
"tag": "direct"
}
],
"route": {
"rules": [
{
"action": "sniff"
},
{
"protocol": "dns",
"action": "hijack-dns"
},
{
"ip_is_private": true,
"outbound": "direct"
},
{
"rule_set": [
"geoip-cn",
"geosite-cn"
],
"outbound": "direct"
}
],
"rule_set": [
{
"type": "remote",
"tag": "geoip-cn",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs",
"download_detour": "proxy"
},
{
"type": "remote",
"tag": "geosite-cn",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-cn.srs",
"download_detour": "proxy"
}
],
"final": "proxy",
"auto_detect_interface": true
}
}
<shadowsocks-host> 替换为shadowsocks服务的主机域名或者IP
<shadowsocks-port>替换为shadowsocks服务的端口号
<shadowsocks-method>替换为shadowsocks服务使用的加密方法
<shadowsocks-password>替换为shadowsocks服务的访问密码
注意:android上sing-box配置文件可能无法直接通过文件导入,需要手工创建本地配置文件,然后编辑内容,把上面的配置文件内容粘贴进去。
License:
CC BY 4.0