sing-box 软路由透明代理 IPv6 + 自动更新订阅 + 代理链

可恶,我也就只有假期能才有空记录点什么东西 = =

每个生活在瓷器国的合格程序员,人生中大概都有那么几个时刻暴怒于糟糕的网络环境。作为被隔离的一代,防火墙教会了我大约半数以上的网络技能,感谢您全家,虽然我更希望能学得不那么扭曲。

这篇文章分享了几个代理设置过程中麻烦问题的解决方案。


代理软件伴随了我在赛博空间的一生,从懵懂时的免费服务,到薅 GAE 羊毛,到自建 ShadowsocksV2Ray 服务器,再到最近几年用 ShellCrash 管理我的订阅。我在各种尝试中总结了以下几个需求:

  • 写入安全:为了避免恶意软件篡改机器的数据,闭源客户端无法被接受。
  • 稳定:时间对所有人类都是平等的宝贵,我没办法说服自己为这外加的束缚浪费时间。我希望能尽可能使用已有的解决方案,而不是自行开发/手动处理。
  • 良好的体验:我不希望为不需要的好处付出体验成本。
  • 读取安全(隐私):我希望降低信息泄漏的可能性。虽然大部分网站使用了 HTTPS 加密,但中间人依然可以读取我正在访问的域名。

ShellCrash 在过去几年能一直能稳定满足一些基本需求,但面对需要高度定制化的隐私需求显得有些鸡肋且束手束脚,而且我也不太喜欢它的防火墙规则写法。于是我捣鼓一套自己的 nftables 规则,跑通之后才发现 sing-box 内置了 nftables 的规则配置,好吧。

这篇文章会忽略简单的让服务可用的部分,记录几个处理起来比较麻烦问题的解决方案。自用的完整配置模板 会在文章最后附带。

IPv6

我家里的宽带分配了 IPv6,但代理服务提供商不支持通过 IPv6 出口流量,这意味着所有的 IPv6 流量都必须通过直连出口。为此,所有 DNS 请求都被劫持为使用 FakeIP 方案,以保证寻常的请求带有完整域名(FQDN)信息抵达代理客户端,推迟 DNS 解析。

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
{
"dns": {
"servers": [
{
"type": "tls",
"tag": "dns_proxy",
"server": "8.8.4.4",
"detour": "🚀 海外网站"
},
{
"type": "fakeip",
"tag": "dns_fakeip",
"inet4_range": "198.18.0.0/16",
"inet6_range": "fc00::/16"
}
],
"rules": [
{
"query_type": [
"A",
"AAAA"
],
"server": "dns_fakeip",
"rewrite_ttl": 1
}
],
"final": "dns_proxy",
"strategy": "ipv4_only"
}
}

IPv6 相关的问题是我选择全部劫持并使用 FakeIP,而不是从真实 IP 嗅探域名的主要原因。

域名嗅探发生在 TCP 三次握手之后,此时浏览器会认为连接已经建立。因此考虑访问境外域名时,若 DNS 解析返回了 IPv6 和 IPv4 地址,浏览器会尝试使用 IPv6 访问目标域名,但我们无法将流量转向直连(因为无法直接访问境外网站);也不能发往代理服务器(前面提到了它不支持 IPv6 出口);同时也不能拒绝连接(TCP 连接建立之后被关闭,浏览器会报 ERR_CONNECTION_CLOSED,而不是尝试回退到 IPv4 地址)。

一个已经被废弃的 sniff_override_destination 选项 允许用嗅探出的域名覆盖 IP 作为请求目标,但作者不打算在后续的版本中保留这个功能,而且考虑有些包可能嗅探不出来域名之类难以 Debug 的烦心事,我自己也不喜欢让嗅探结果影响主要功能这种半吊子的方案。

另外,因为设备可能使用了 DoH,代理软件不总是能劫持 DNS 请求,因此仅过滤 DNS 结果中的 IPv6 也不能完全避免 IPv6 请求。另外一种可能的方式是关闭路由器对 IPv6 流量的劫持,不通过代理软件而是让防火墙拒绝我们的流量。但这可能会导致 IPv6 请求泄露,暴露我们尝试访问的域名,而自行编写拦截 IPv6 的防火墙规则则不在我的考虑范围内。理论上,我们应当可以让代理软件在嗅探域名之前拒绝所有 IPv6 的数据包,但 sing-box 似乎没有很好处理这种情况。于是最终,我选择在 nftables 中拦截所有的路由器 IPv6 子网流量。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
table inet firewall {
chain filter_ipv6_out {
type filter hook prerouting priority mangle; policy accept;

# Our proxy nodes don't support IPv6.
# Immediately reject connection attempts to IPv6 addresses. This is to prevent
# connection failures caused by clients (using DoH) resolving IPv6 addresses,
# and to correctly trigger the client's fallback to IPv4.
meta nfproto != ipv6 accept
iifname != "br-lan" accept
fib daddr oifname != "enp2s0" accept

ct state new counter reject
}
}

使用这种方案时,即使是可以直连的域名也不能在设备上直接通过 IPv6 访问,因此为直连请求返回真实 IP 地址没有意义。

1
2
3
4
5
6
7
8
9
10
11
12
{
"outbounds": [
{
"tag": "Direct",
"type": "direct",
"domain_resolver": {
"server": "dns_direct",
"strategy": "prefer_ipv4"
}
}
]
}

在代理的直连出口选择 prefer_ipv4/prefer_ipv6 可以让代理解析 DNS 时尝试使用 IPv6 访问直连地址。

在这一套方案下,外部可以通过 IPv6 访问路由器下的设备,设备也可以使用域名通过 IPv6 直连访问其它服务。

自动更新订阅

Subconverter 的 Fork 版本 支持生成 sing-box 配置,但使用的是内置的 sing-box 配置模板,在 sing-box 更新改动了配置格式时(作者经常在只更改 minor 版本号的情况下这么做,上帝保佑)无法及时生产支持新版本的配置文件;SurgioSub-Store 看起来不错,但是需要带状态的后端服务,太麻烦了。最后我选择的是 sing-box-subscribe,虽然它的代码写得实在有够乱,但考虑到它能直接部署在 Vercel 上无状态使用,我也就不苛求太多。

直接用 crontab 解决自动更新问题:

1
2
3
4
5
curl 'https://<VERCEL_SERVICE_URL>/config/<SUBSCRIPTION_URL>&file=https://gist.githubusercontent.com/Hanssen0/0e3eef2400e832d0ee98b46f01f4e23b/raw/sing-box-template.json' > /etc/sing-box/config.json

sing-box check -C /etc/sing-box && systemctl restart sing-box

#0 0 * * * sh /etc/sing-box/sync.sh

代理链

远端代理服务器我选择了 VMess 协议 + CDN (+ WebSocket) 的方案,向前置代理隐藏服务器的真实 IP 地址。服务端依然使用 sing-box 搭建,使用 Caddy 反向代理方便配置 TLS 证书。

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
{
"dns": {
"servers": [
{
"type": "local",
"tag": "dns_direct"
}
],
"final": "dns_direct"
},
"inbounds": [
{
"listen": "127.0.0.1",
"listen_port": 9999,
"tag": "in",
"type": "vmess",
"users": [
{
"name": "YOUR_USERNAME",
"uuid": "00000000-0000-0000-0000-000000000000",
"alterId": 0
}
],
"transport": {
"type": "ws",
"path": "/WEBSOCKET_PATH"
}
}
],
"outbounds": [
{
"tag": "Direct",
"type": "direct"
}
],
"route": {
"final": "Direct",
"auto_detect_interface": true,
"default_domain_resolver": {
"server": "dns_direct"
},
"rules": [
{
"ip_is_private": true,
"action": "reject"
}
]
}
}
1
2
3
4
5
6
7
8
9
10
YOUR_DOMAIN {
log {
output stdout
}

reverse_proxy /WEBSOCKET_PATH localhost:9999

root * /etc/caddy/root
file_server
}

需要注意的是,我不希望公开代理服务器的 IP 地址,但依然希望做到自动更新订阅。因此,我使用了服务器更新订阅,而客户端从服务器获取配置的方案。config_linux.jsonconfig_android.json 储存了平台特定的配置,而 config_common.json 则保存了代理服务器的信息。因为 HTTPS 请求只会公开域名,而不会公开 URL 路径,将访问密码添加到路径中是相对安全的操作(但不推荐,这是为了让 Android 客户端能直接使用订阅链接)。

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
// config_linux.json

{
"experimental": {
"clash_api": {
"external_controller": "0.0.0.0:9090",
"external_ui": "ui",
"secret": "",
"external_ui_download_url": "https://gh-proxy.com/https://github.com/Zephyruso/zashboard/archive/refs/heads/gh-pages.zip",
"external_ui_download_detour": "🚀 节点选择",
"default_mode": "rule"
} // Unnecessary on Android
},
"inbounds": [
{
"tag": "tun-in",
"type": "tun",
"address": [
"172.19.0.0/30",
"fdfe:dcba:9876::1/126"
],
"auto_route": true,
"auto_redirect": true, // Remove this on Android
"strict_route": true
}
]
}
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
// config_common.json

{
"outbounds": [
{
"tag": "🪞 自建节点 - 链式代理",
"type": "vmess",
"server": "<YOUR_DOMAIN>",
"server_port": 443,
"uuid": "00000000-0000-0000-0000-000000000000",
"alter_id": 0,
"tls": {
"enabled": true
},
"transport": {
"type": "ws",
"path": "/WEBSOCKET_PATH",
"headers": {
"Host": "<YOUR_DOMAIN>"
}
},
"detour": "🔗 链式代理 - 前置"
}
]
}
1
2
3
4
5
6
7
8
9
10
# Server

curl 'https://<VERCEL_SERVICE_URL>/config/<SUBSCRIPTION_URL>&file=https://gist.githubusercontent.com/Hanssen0/0e3eef2400e832d0ee98b46f01f4e23b/raw/sing-box-template.json' > /etc/sing-box/client/config.json

sing-box merge -c /etc/sing-box/client/config_linux.json -c /etc/sing-box/client/config.json -c /etc/sing-box/client/config_common.json /etc/caddy/root/<SERVER_SECRET>/config_linux.json
sing-box merge -c /etc/sing-box/client/config_android.json -c /etc/sing-box/client/config.json -c /etc/sing-box/client/config_common.json /etc/caddy/root/<SERVER_SECRET>/config_android.json

chown -R caddy:caddy /etc/caddy/root/

#0 23 * * * sh /etc/sing-box/sync.sh
1
2
3
4
5
6
# Client
curl 'https://<YOUR_DOMAIN>/<SERVER_SECRET>/config_linux.json' > /etc/sing-box/config.json

sing-box check -C /etc/sing-box && systemctl restart sing-box

#0 0 * * * sh /etc/sing-box/sync.sh

自用完整配置模板 - 2025-10-02

Steam 下载和 NTP 服务都是走的直连。

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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
{
"log": {
"level": "info",
"timestamp": true
},
"experimental": {
"cache_file": {
"enabled": true,
"store_fakeip": true
}
},
"dns": {
"servers": [
{
"type": "tls",
"tag": "dns_proxy",
"server": "8.8.4.4",
"detour": "🚀 海外网站"
},
{
"type": "udp",
"tag": "dns_direct",
"server": "223.5.5.5"
},
{
"type": "fakeip",
"tag": "dns_fakeip",
"inet4_range": "198.18.0.0/16",
"inet6_range": "fc00::/16"
}
],
"rules": [
{
"clash_mode": "Direct",
"server": "dns_direct",
"strategy": "prefer_ipv4"
},
{
"query_type": [
"A",
"AAAA"
],
"clash_mode": "Global",
"server": "dns_fakeip",
"rewrite_ttl": 1
},
{
"clash_mode": "Global",
"server": "dns_proxy"
},
{
"query_type": [
"A",
"AAAA"
],
"server": "dns_fakeip",
"rewrite_ttl": 1
}
],
"final": "dns_proxy",
"strategy": "ipv4_only",
"independent_cache": true,
"reverse_mapping": true
},
"outbounds": [
{
"tag": "✋ 手动切换",
"type": "selector",
"outbounds": [
"{all}",
"Direct",
"🪞 自建节点 - 链式代理"
]
},
{
"tag": "🚀 节点选择",
"type": "selector",
"outbounds": [
"♻️ 自动选择",
"Direct",
"🪞 自建节点 - 链式代理",
"✋ 手动切换",
"🛏️ 日常使用",
"📺 省流节点",
"👍 高级节点",
"🇭🇰 香港节点",
"🇨🇳 台湾节点",
"🇸🇬 新加坡节点",
"🇯🇵 日本节点",
"🇺🇲 美国节点",
"🇰🇷 韩国节点",
"❓ 其它节点"
]
},
{
"tag": "🔗 链式代理 - 前置",
"type": "selector",
"outbounds": [
"♻️ 自动选择",
"Direct",
"🛏️ 日常使用",
"📺 省流节点",
"👍 高级节点",
"🇭🇰 香港节点",
"🇨🇳 台湾节点",
"🇸🇬 新加坡节点",
"🇯🇵 日本节点",
"🇺🇲 美国节点",
"🇰🇷 韩国节点",
"❓ 其它节点",
"{all}"
]
},
{
"tag": "🛑 广告拦截",
"type": "selector",
"outbounds": [
"Block",
"Direct"
]
},
{
"tag": "🎥 YouTube",
"type": "selector",
"outbounds": [
"🚀 节点选择",
"Direct",
"🪞 自建节点 - 链式代理",
"✋ 手动切换",
"♻️ 自动选择",
"🛏️ 日常使用",
"📺 省流节点",
"👍 高级节点",
"🇭🇰 香港节点",
"🇨🇳 台湾节点",
"🇸🇬 新加坡节点",
"🇯🇵 日本节点",
"🇺🇲 美国节点",
"🇰🇷 韩国节点",
"❓ 其它节点"
]
},
{
"tag": "🎥 F1 TV",
"type": "selector",
"outbounds": [
"🚀 节点选择",
"Direct",
"🪞 自建节点 - 链式代理",
"✋ 手动切换",
"♻️ 自动选择",
"🛏️ 日常使用",
"📺 省流节点",
"👍 高级节点",
"🇭🇰 香港节点",
"🇨🇳 台湾节点",
"🇸🇬 新加坡节点",
"🇯🇵 日本节点",
"🇺🇲 美国节点",
"🇰🇷 韩国节点",
"❓ 其它节点"
]
},
{
"tag": "🤖 海外 AI",
"type": "selector",
"outbounds": [
"🚀 节点选择",
"Direct",
"🪞 自建节点 - 链式代理",
"✋ 手动切换",
"♻️ 自动选择",
"🛏️ 日常使用",
"📺 省流节点",
"👍 高级节点",
"🇭🇰 香港节点",
"🇨🇳 台湾节点",
"🇸🇬 新加坡节点",
"🇯🇵 日本节点",
"🇺🇲 美国节点",
"🇰🇷 韩国节点",
"❓ 其它节点"
]
},
{
"tag": "🪙 国内交易所",
"type": "selector",
"outbounds": [
"🚀 节点选择",
"Direct",
"🪞 自建节点 - 链式代理",
"✋ 手动切换",
"♻️ 自动选择",
"🛏️ 日常使用",
"📺 省流节点",
"👍 高级节点",
"🇭🇰 香港节点",
"🇨🇳 台湾节点",
"🇸🇬 新加坡节点",
"🇯🇵 日本节点",
"🇺🇲 美国节点",
"🇰🇷 韩国节点",
"❓ 其它节点"
]
},
{
"tag": " 全球直连",
"type": "selector",
"outbounds": [
"🚀 节点选择",
"Direct",
"🪞 自建节点 - 链式代理",
"✋ 手动切换",
"♻️ 自动选择",
"🛏️ 日常使用",
"📺 省流节点",
"👍 高级节点",
"🇭🇰 香港节点",
"🇨🇳 台湾节点",
"🇸🇬 新加坡节点",
"🇯🇵 日本节点",
"🇺🇲 美国节点",
"🇰🇷 韩国节点",
"❓ 其它节点"
]
},
{
"tag": "🚀 海外网站",
"type": "selector",
"outbounds": [
"🚀 节点选择",
"Direct",
"🪞 自建节点 - 链式代理",
"✋ 手动切换",
"♻️ 自动选择",
"🛏️ 日常使用",
"📺 省流节点",
"👍 高级节点",
"🇭🇰 香港节点",
"🇨🇳 台湾节点",
"🇸🇬 新加坡节点",
"🇯🇵 日本节点",
"🇺🇲 美国节点",
"🇰🇷 韩国节点",
"❓ 其它节点"
]
},
{
"tag": "❤️ 常用端口",
"type": "selector",
"outbounds": [
"🚀 节点选择",
"Direct",
"🪞 自建节点 - 链式代理",
"✋ 手动切换",
"♻️ 自动选择",
"🛏️ 日常使用",
"📺 省流节点",
"👍 高级节点",
"🇭🇰 香港节点",
"🇨🇳 台湾节点",
"🇸🇬 新加坡节点",
"🇯🇵 日本节点",
"🇺🇲 美国节点",
"🇰🇷 韩国节点",
"❓ 其它节点"
]
},
{
"tag": "🔐 22 端口",
"type": "selector",
"outbounds": [
"🚀 节点选择",
"Direct",
"🪞 自建节点 - 链式代理",
"✋ 手动切换",
"♻️ 自动选择",
"🛏️ 日常使用",
"📺 省流节点",
"👍 高级节点",
"🇭🇰 香港节点",
"🇨🇳 台湾节点",
"🇸🇬 新加坡节点",
"🇯🇵 日本节点",
"🇺🇲 美国节点",
"🇰🇷 韩国节点",
"❓ 其它节点"
]
},
{
"tag": "🐟 漏网之鱼",
"type": "selector",
"outbounds": [
"🚀 节点选择",
"Direct",
"🪞 自建节点 - 链式代理",
"✋ 手动切换",
"♻️ 自动选择",
"🛏️ 日常使用",
"📺 省流节点",
"👍 高级节点",
"🇭🇰 香港节点",
"🇨🇳 台湾节点",
"🇸🇬 新加坡节点",
"🇯🇵 日本节点",
"🇺🇲 美国节点",
"🇰🇷 韩国节点",
"❓ 其它节点"
]
},
{
"tag": "🛏️ 日常使用",
"type": "urltest",
"outbounds": [
"{all}"
],
"filter": [
{
"action": "include",
"keywords": [
"0.[0-5]|低倍率|省流|大流量"
]
},
{
"action": "exclude",
"keywords": [
"网站|地址|剩余|过期|时间|有效|Traffic|Expire"
]
},
{
"action": "exclude",
"keywords": [
"🇯🇵|JP|jp|日本|Japan|川日|东京|大阪|泉日|埼玉|沪日|深日"
]
}
]
},
{
"tag": "📺 省流节点",
"type": "urltest",
"outbounds": [
"{all}"
],
"filter": [
{
"action": "include",
"keywords": [
"0.[0-5]|低倍率|省流|大流量"
]
},
{
"action": "exclude",
"keywords": [
"网站|地址|剩余|过期|时间|有效|Traffic|Expire"
]
}
]
},
{
"tag": "👍 高级节点",
"type": "urltest",
"outbounds": [
"{all}"
],
"filter": [
{
"action": "include",
"keywords": [
"专线|专用|高级|直连|急速|高倍率|IEPL|IPLC|AIA|CTM|CC|iepl|iplc|aia|ctm|cc|AC"
]
},
{
"action": "exclude",
"keywords": [
"0.[0-5]|低倍率|省流|大流量"
]
}
]
},
{
"tag": "♻️ 自动选择",
"type": "urltest",
"outbounds": [
"{all}"
],
"filter": [
{
"action": "exclude",
"keywords": [
"网站|地址|剩余|过期|时间|有效|Traffic|Expire"
]
}
]
},
{
"tag": "🇭🇰 香港节点",
"type": "urltest",
"outbounds": [
"{all}"
],
"filter": [
{
"action": "include",
"keywords": [
"🇭🇰|HK|hk|港|HongKong"
]
}
]
},
{
"tag": "🇨🇳 台湾节点",
"type": "urltest",
"outbounds": [
"{all}"
],
"filter": [
{
"action": "include",
"keywords": [
"🇹🇼|TW|tw|臺灣|台|Taiwan|新北|彰化"
]
}
]
},
{
"tag": "🇸🇬 新加坡节点",
"type": "urltest",
"outbounds": [
"{all}"
],
"filter": [
{
"action": "include",
"keywords": [
"🇸🇬|SG|sg|坡|狮|Singapore"
]
}
]
},
{
"tag": "🇯🇵 日本节点",
"type": "urltest",
"outbounds": [
"{all}"
],
"filter": [
{
"action": "include",
"keywords": [
"🇯🇵|JP|jp|日本|Japan|川日|东京|大阪|泉日|埼玉|沪日|深日"
]
}
]
},
{
"tag": "🇺🇲 美国节点",
"type": "urltest",
"outbounds": [
"{all}"
],
"filter": [
{
"action": "include",
"keywords": [
"🇺🇸|US|us|美国|美|United States|波特兰|达拉斯|俄勒冈|凤凰城|费利蒙|硅谷|拉斯维加斯|洛杉矶|圣何塞|圣克拉拉|西雅图|芝加哥"
]
}
]
},
{
"tag": "🇰🇷 韩国节点",
"type": "urltest",
"outbounds": [
"{all}"
],
"filter": [
{
"action": "include",
"keywords": [
"🇰🇷|KR|Korea|KOR|首尔|韩|韓"
]
}
]
},
{
"tag": "❓ 其它节点",
"type": "selector",
"outbounds": [
"{all}"
],
"filter": [
{
"action": "exclude",
"keywords": [
"🇭🇰|HK|hk|港|HongKong|🇹🇼|TW|tw|臺灣|台|Taiwan|新北|彰化|🇸🇬|SG|sg|坡|狮|Singapore|🇯🇵|JP|jp|日本|Japan|川日|东京|大阪|泉日|埼玉|沪日|深日|🇺🇸|US|us|美国|美|United States|波特兰|达拉斯|俄勒冈|凤凰城|费利蒙|硅谷|拉斯维加斯|洛杉矶|圣何塞|圣克拉拉|西雅图|芝加哥|🇰🇷|KR|Korea|KOR|首尔|韩|韓"
]
},
{
"action": "exclude",
"keywords": [
"网站|地址|剩余|过期|时间|有效|Traffic|Expire"
]
}
]
},
{
"tag": "Direct",
"type": "direct",
"domain_resolver": {
"server": "dns_direct",
"strategy": "prefer_ipv4"
}
},
{
"tag": "Block",
"type": "block"
}
],
"route": {
"final": "🐟 漏网之鱼",
"auto_detect_interface": true,
"default_domain_resolver": {
"server": "dns_direct",
"strategy": "prefer_ipv4"
},
"rules": [
{
"action": "sniff"
},
{
"type": "logical",
"mode": "or",
"rules": [
{
"protocol": "dns"
},
{
"port": 53
}
],
"action": "hijack-dns"
},
{
"ip_is_private": true,
"outbound": "Direct"
},
{
"clash_mode": "Direct",
"outbound": "Direct"
},
{
"clash_mode": "Global",
"outbound": "🚀 海外网站"
},
{
"rule_set": [
"geosite-category-ads-all"
],
"outbound": "🛑 广告拦截"
},
{
"rule_set": [
"geosite-youtube"
],
"outbound": "🎥 YouTube"
},
{
"domain_suffix": [
"formula1.com"
],
"outbound": "🎥 F1 TV"
},
{
"rule_set": [
"geosite-category-ai-!cn"
],
"outbound": "🤖 海外 AI"
},
{
"type": "logical",
"mode": "and",
"rules": [
{
"rule_set": [
"geosite-binance",
"geosite-huobi",
"geosite-okx"
]
},
{
"domain": [
"www.okx.com",
"web3.okx.com",
"wallet.okx.com"
],
"invert": true
}
],
"outbound": "🪙 国内交易所"
},
{
"type": "logical",
"mode": "and",
"rules": [
{
"rule_set": [
"geosite-geolocation-cn",
"geosite-tld-cn",
"geoip-cn",
"geosite-steam",
"geosite-category-ntp"
]
},
{
"rule_set": [
"geosite-google@cn"
],
"domain_suffix": [
"steampowered.com",
"steamcommunity.com",
"steamstatic.com",
"steamusercontent.com"
],
"invert": true
}
],
"outbound": "🎯 全球直连"
},
{
"rule_set": [
"geosite-geolocation-!cn",
"geosite-tld-!cn"
],
"outbound": "🚀 海外网站"
},
{
"port": [
80,
443,
4950,
4955,
6699
],
"outbound": "❤️ 常用端口"
},
{
"port": 22,
"outbound": "🔐 22 端口"
}
],
"rule_set": [
{
"tag": "geosite-category-ntp",
"type": "remote",
"format": "binary",
"url": "https://github.com/SagerNet/sing-geosite/raw/refs/heads/rule-set/geosite-category-ntp.srs",
"download_detour": "🚀 海外网站"
},
{
"tag": "geosite-geolocation-!cn",
"type": "remote",
"format": "binary",
"url": "https://github.com/SagerNet/sing-geosite/raw/refs/heads/rule-set/geosite-geolocation-!cn.srs",
"download_detour": "🚀 海外网站"
},
{
"tag": "geosite-tld-!cn",
"type": "remote",
"format": "binary",
"url": "https://github.com/SagerNet/sing-geosite/raw/refs/heads/rule-set/geosite-tld-!cn.srs",
"download_detour": "🚀 海外网站"
},
{
"tag": "geosite-category-ads-all",
"type": "remote",
"format": "binary",
"url": "https://github.com/SagerNet/sing-geosite/raw/refs/heads/rule-set/geosite-category-ads-all.srs",
"download_detour": "🚀 海外网站"
},
{
"tag": "geosite-youtube",
"type": "remote",
"format": "binary",
"url": "https://github.com/SagerNet/sing-geosite/raw/refs/heads/rule-set/geosite-youtube.srs",
"download_detour": "🚀 海外网站"
},
{
"tag": "geosite-category-ai-!cn",
"type": "remote",
"format": "binary",
"url": "https://github.com/SagerNet/sing-geosite/raw/refs/heads/rule-set/geosite-category-ai-!cn.srs",
"download_detour": "🚀 海外网站"
},
{
"tag": "geosite-binance",
"type": "remote",
"format": "binary",
"url": "https://github.com/SagerNet/sing-geosite/raw/refs/heads/rule-set/geosite-binance.srs",
"download_detour": "🚀 海外网站"
},
{
"tag": "geosite-huobi",
"type": "remote",
"format": "binary",
"url": "https://github.com/SagerNet/sing-geosite/raw/refs/heads/rule-set/geosite-huobi.srs",
"download_detour": "🚀 海外网站"
},
{
"tag": "geosite-okx",
"type": "remote",
"format": "binary",
"url": "https://github.com/SagerNet/sing-geosite/raw/refs/heads/rule-set/geosite-okx.srs",
"download_detour": "🚀 海外网站"
},
{
"tag": "geosite-google@cn",
"type": "remote",
"format": "binary",
"url": "https://github.com/SagerNet/sing-geosite/raw/refs/heads/rule-set/geosite-google@cn.srs",
"download_detour": "🚀 海外网站"
},
{
"tag": "geosite-geolocation-cn",
"type": "remote",
"format": "binary",
"url": "https://github.com/SagerNet/sing-geosite/raw/refs/heads/rule-set/geosite-geolocation-cn.srs",
"download_detour": "🚀 海外网站"
},
{
"tag": "geosite-tld-cn",
"type": "remote",
"format": "binary",
"url": "https://github.com/SagerNet/sing-geosite/raw/refs/heads/rule-set/geosite-tld-cn.srs",
"download_detour": "🚀 海外网站"
},
{
"tag": "geoip-cn",
"type": "remote",
"format": "binary",
"url": "https://github.com/SagerNet/sing-geoip/raw/refs/heads/rule-set/geoip-cn.srs",
"download_detour": "🚀 海外网站"
},
{
"tag": "geosite-steam",
"type": "remote",
"format": "binary",
"url": "https://github.com/SagerNet/sing-geosite/raw/refs/heads/rule-set/geosite-steam.srs",
"download_detour": "🚀 海外网站"
}
]
}
}