分享 ShellCrash 搭载 sing-boxp 内核采用 geodata 方案的一套配置
此方案适用于 sing-box,搭载 sing-boxp 内核,采用 `geosite` 和 `geoip` 规则搭配 geosite.db 和 geoip.db 路由规则文件
声明:
- 请根据自身情况进行修改,适合自己的方案才是最好的方案,如无特殊需求,可以照搬
- 此方案适用于 ShellCrash(以 arm64 架构为例,且安装路径为 /data/ShellCrash)
- 此方案已摒弃 AdGuard Home,但拦截广告效果依然强劲
一、 生成配置文件 .json 文件直链
具体方法此处不再赘述,请看《生成带有自定义出站和规则的 sing-box 配置文件直链-geodata 方案》,贴一下我使用的配置:
- 注:
route.rules
部分的geosite
和geoip
内容须与route.geosite
和route.geoip
中的路由规则文件相匹配
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
{
"outbounds": [
{ "tag": "🚀 节点选择", "type": "selector", "outbounds": [ "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇰🇷 韩国节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点", "🆓 免费节点" ] },
{ "tag": "🐟 漏网之鱼", "type": "selector", "outbounds": [ "🚀 节点选择", "🎯 全球直连" ] },
{ "tag": "📈 网络测试", "type": "selector", "outbounds": [ "🎯 全球直连", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇰🇷 韩国节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点", "🆓 免费节点" ] },
{ "tag": "🤖 人工智能", "type": "selector", "outbounds": [ "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇰🇷 韩国节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点" ] },
{ "tag": "🎮 游戏服务", "type": "selector", "outbounds": [ "🎯 全球直连", "🚀 节点选择" ] },
{ "tag": "🪟 微软服务", "type": "selector", "outbounds": [ "🎯 全球直连", "🚀 节点选择" ] },
{ "tag": "🇬 谷歌服务", "type": "selector", "outbounds": [ "🎯 全球直连", "🚀 节点选择" ] },
{ "tag": "🍎 苹果服务", "type": "selector", "outbounds": [ "🎯 全球直连", "🚀 节点选择" ] },
{ "tag": "🇨🇳 直连域名", "type": "selector", "outbounds": [ "🎯 全球直连", "🚀 节点选择" ] },
{ "tag": "🇨🇳 直连 IP", "type": "selector", "outbounds": [ "🎯 全球直连", "🚀 节点选择" ] },
{ "tag": "🪜 代理域名", "type": "selector", "outbounds": [ "🚀 节点选择", "🎯 全球直连" ] },
{ "tag": "📲 电报消息", "type": "selector", "outbounds": [ "🚀 节点选择" ] },
{ "tag": "🔒 私有网络", "type": "selector", "outbounds": [ "🎯 全球直连" ] },
{ "tag": "🛑 广告拦截", "type": "selector", "outbounds": [ "REJECT" ] },
{ "tag": "🎯 全球直连", "type": "selector", "outbounds": [ "DIRECT" ] },
{ "tag": "REJECT", "type": "block" },
{ "tag": "DIRECT", "type": "direct" },
{ "tag": "GLOBAL", "type": "selector", "outbounds": [ "DIRECT", "REJECT", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇰🇷 韩国节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点", "🆓 免费节点" ] },
{ "tag": "dns-out", "type": "dns" },
// 若没有单个出站节点,须删除所有 `🆓 免费节点` 相关内容
{
"tag": "🆓 免费节点",
"type": "vless",
"server": "example.com",
"server_port": 443,
"uuid": "{uuid}",
"network": "tcp",
"tls": { "enabled": true, "server_name": "example.com", "insecure": false },
"transport": { "type": "ws", "path": "/?ed=2048", "headers": { "Host": "example.com" } }
},
{ "tag": "🇭🇰 香港节点", "type": "urltest", "tolerance": 50, "use_all_providers": true, "includes": [ "🇭🇰" ] },
{ "tag": "🇹🇼 台湾节点", "type": "urltest", "tolerance": 50, "use_all_providers": true, "includes": [ "🇹🇼" ] },
{ "tag": "🇯🇵 日本节点", "type": "urltest", "tolerance": 50, "use_all_providers": true, "includes": [ "🇯🇵" ] },
{ "tag": "🇰🇷 韩国节点", "type": "urltest", "tolerance": 50, "use_all_providers": true, "includes": [ "🇰🇷" ] },
{ "tag": "🇸🇬 新加坡节点", "type": "urltest", "tolerance": 50, "use_all_providers": true, "includes": [ "🇸🇬" ] },
{ "tag": "🇺🇸 美国节点", "type": "urltest", "tolerance": 50, "use_all_providers": true, "includes": [ "🇺🇸" ] }
],
"outbound_providers": [
{
"tag": "🛫 我的机场",
"type": "remote",
// 修改为你的 Clash 订阅链接
"download_url": "https://example.com/xxx/xxx&flag=clash",
"path": "./providers/airport.yaml",
"download_interval": "24h",
"download_ua": "clash.meta",
"includes": [ "🇭🇰|🇹🇼|🇯🇵|🇰🇷|🇸🇬|🇺🇸" ],
"healthcheck_url": "https://www.gstatic.com/generate_204",
"healthcheck_interval": "10m"
}
],
"route": {
"rules": [
{ "protocol": [ "dns" ], "outbound": "dns-out" },
{ "clash_mode": [ "Direct" ], "outbound": "DIRECT" },
{ "clash_mode": [ "Global" ], "outbound": "GLOBAL" },
{ "geosite": [ "private" ], "outbound": "🔒 私有网络" },
{ "geosite": [ "ads" ], "outbound": "🛑 广告拦截" },
{ "geosite": [ "microsoft-cn" ], "outbound": "🪟 微软服务" },
{ "geosite": [ "apple-cn" ], "outbound": "🍎 苹果服务" },
{ "geosite": [ "google-cn" ], "outbound": "🇬 谷歌服务" },
{ "geosite": [ "games-cn" ], "outbound": "🎮 游戏服务" },
{ "geosite": [ "ai" ], "outbound": "🤖 人工智能" },
{ "geosite": [ "networktest" ], "outbound": "📈 网络测试" },
{ "geosite": [ "proxy" ], "outbound": "🪜 代理域名" },
{ "geosite": [ "cn" ], "outbound": "🇨🇳 直连域名" },
{ "geoip": [ "telegram" ], "outbound": "📲 电报消息", "skip_resolve": true },
{ "geoip": [ "private" ], "outbound": "🔒 私有网络", "skip_resolve": true },
{ "geoip": [ "cn" ], "outbound": "🇨🇳 直连 IP" }
],
"geosite": {
"path": "./geosite.db",
"download_url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box/geosite.db"
},
"geoip": {
"path": "./geoip.db",
"download_url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box/geoip-lite.db"
},
"final": "🐟 漏网之鱼",
"auto_detect_interface": true,
"concurrent_dial": true
}
}
二、 导入 sing-box PuerNya 版内核
连接 SSH 后运行如下命令:
1
curl -L https://cdn.jsdelivr.net/gh/DustinWin/clash_singbox-tools@sing-box/sing-box-puernya-linux-armv8.tar.gz | tar -zx -C /tmp/ && crash
此时脚本会自动“发现可用的内核文件”,选择 1 加载,后选择 5 Sing-Box-Puer 内核
三、 导入路由规则文件
连接 SSH 后运行如下命令:
1
2
curl -o $CRASHDIR/geosite.db -L https://cdn.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box/geosite.db
curl -o $CRASHDIR/geoip.db -L https://cdn.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box/geoip-lite.db
四、 编辑 dns.json 文件
连接 SSH 后运行 vi $CRASHDIR/jsons/dns.json
,按一下 Ins 键(Insert 键),粘贴如下内容:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{
"dns": {
"hosts": {
"miwifi.com": [ "192.168.31.1" ],
"doh.pub": [ "1.12.12.12", "120.53.53.53", "2402:4e00::" ],
"dns.alidns.com": [ "223.5.5.5", "223.6.6.6", "2400:3200::1", "2400:3200:baba::1" ],
"dns.google": [ "8.8.8.8", "8.8.4.4", "2001:4860:4860::8888", "2001:4860:4860::8844" ],
"cloudflare-dns.com": [ "1.1.1.1", "1.0.0.1", "2606:4700:4700::1111", "2606:4700:4700::1001" ]
},
"servers": [
{ "tag": "dns_block", "address": "rcode://success" },
{ "tag": "dns_direct", "address": [ "https://doh.pub/dns-query", "https://dns.alidns.com/dns-query" ], "detour": "DIRECT" },
{ "tag": "dns_proxy", "address": [ "https://dns.google/dns-query", "https://cloudflare-dns.com/dns-query" ] },
{ "tag": "dns_fakeip", "address": "fakeip" }
],
"rules": [
{ "outbound": [ "any" ], "server": "dns_direct" },
{ "clash_mode": [ "Direct" ], "query_type": [ "A", "AAAA" ], "server": "dns_direct" },
{ "clash_mode": [ "Global" ], "query_type": [ "A", "AAAA" ], "server": "dns_proxy" },
{ "geosite": [ "ads" ], "server": "dns_block", "disable_cache": true, "rewrite_ttl": 0 },
{ "geosite": [ "proxy" ], "query_type": [ "A", "AAAA" ], "server": "dns_fakeip", "rewrite_ttl": 1 },
{ "geosite": [ "cn" ], "query_type": [ "A", "AAAA" ], "server": "dns_direct" },
{ "fallback_rules": [ { "geoip": [ "cn" ], "server": "dns_direct" }, { "match_all": true, "server": "dns_fakeip", "rewrite_ttl": 1 } ], "server": "dns_proxy", "allow_fallthrough": true }
],
"final": "dns_direct",
"strategy": "prefer_ipv4",
"independent_cache": true,
"lazy_cache": true,
"reverse_mapping": true,
"mapping_override": true,
"fakeip": {
"enabled": true,
"inet4_range": "198.18.0.0/15",
"inet6_range": "fc00::/18",
"exclude_rule": { "geosite": [ "fakeip-filter", "private" ] }
}
}
}
按一下 Esc 键(退出键),输入英文冒号 :
,继续输入 wq
并回车
五、 添加定时任务
- 连接 SSH 后运行
vi $CRASHDIR/task/task.user
,按一下 Ins 键(Insert 键),粘贴如下内容:
1
2
201#curl -o /data/ShellCrash/CrashCore.tar.gz -L https://ghp.ci/https://github.com/DustinWin/clash_singbox-tools/releases/download/sing-box/sing-box-puernya-linux-armv8.tar.gz && /data/ShellCrash/start.sh restart >/dev/null 2>&1#更新sing-box_PuerNya版内核
202#curl -o /data/ShellCrash/geosite.db -L https://ghp.ci/https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box/geosite.db && curl -o /data/ShellCrash/geoip.db -L https://ghp.ci/https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box/geoip-lite.db && /data/ShellCrash/start.sh restart >/dev/null 2>&1#更新geodata路由规则文件
- 按一下 Esc 键(退出键),输入英文冒号
:
,继续输入wq
并回车 - 执行
crash
,进入 ShellCrash -> 5 配置自动任务 -> 1 添加自动任务,可以看到末尾就有添加的定时任务,输入对应的数字并回车后可设置执行条件
六、 新建文件夹
连接 SSH 后执行命令 mkdir -p $CRASHDIR/providers/
- 注:因
outbound_providers
代理集合配置的path
路径中含有文件夹“providers”,须手动新建此文件夹才能使 .yaml 订阅文件保存到本地,否则将保存到内存中(每次启动服务都要重新下载)
七、 设置部分
- 设置可参考《ShellCrash 搭载 sing-boxp 内核的配置-geodata 方案》,此处只列举配置的不同之处
进入主菜单 -> 2 内核功能设置 -> 2 切换 DNS 模式,选择 1 fake-ip 模式(不会与导入 mix 模式的 dns.json 冲突)
- 进入主菜单 -> 7 内核进阶设置 -> 5 自定义端口及秘钥,设置为
9090
- 进入主菜单 -> 6 导入配置文件 -> 2 在线获取完整配置文件,粘贴第《一》步中生成的配置文件 .json 文件直链,启动服务即可
七、 在线 Dashboard 面板
推荐使用在线 Dashboard 面板 metacubexd,访问地址:https://metacubex.github.io/metacubexd/
需要设置该网站“允许不安全内容”,以 Chrome 浏览器为例,进入设置 -> 隐私和安全 -> 网站设置 -> 更多内容设置 -> 不安全内容(或者直接打开
chrome://settings/content/insecureContent
进行设置),在“允许显示不安全内容”内添加metacubex.github.io
首次进入 https://metacubex.github.io/metacubexd/ 需要添加“后端地址”,输入
http://192.168.31.1:9090
并点击“添加”即可访问 Dashboard 面板