Sing-box (客户端)配置模版
本文主要对 Sing-box 客户端提供一份配置模版。
Sing-box (客户端)配置模版
Sing-box 是一个基于 SagerNet 的代理工具,支持多种协议和功能。其配置文件通常使用 JSON 格式编写,包含了日志、DNS、入站、出站以及路由等相关设置。
1.配置结构
Sing-box 使用 JSON 作为配置文件格式。配置结构如下:
1
2
3
4
5
6
7
8
{
"log": {},
"dns": {},
"inbounds": [],
"outbounds": [],
"route": {},
"experimental": {}
}
2.配置模版
2.1 日志(log)配置模板
1
2
3
4
5
6
7
{
"log": {
"disabled": false,
"level": "info",
"timestamp": true
}
}
2.2 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
31
32
33
{
"dns": {
"servers": [
{
"tag": "google",
"address": "udp://8.8.8.8"
},
{
"tag": "local",
"address": "223.5.5.5",
"detour": "direct"
}
],
"rules": [
{
"outbound": "any",
"server": "local"
},
{
"clash_mode": "Direct",
"server": "local"
},
{
"clash_mode": "Global",
"server": "google"
},
{
"rule_set": "geosite-geolocation-cn",
"server": "local"
}
]
}
}
2.3 路由(route)配置模板
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
{
"route": {
"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": ["geoip-cn", "geosite-geolocation-cn"],
"outbound": "direct"
},
{
"domain_suffix": ["cloudflare.com", "cloudflare.dev"],
"outbound": "direct"
}
],
"rule_set": [
{
"tag": "geoip-cn",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs",
"download_detour": "节点选择"
},
{
"tag": "geosite-geolocation-cn",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-cn.srs",
"download_detour": "节点选择"
}
],
"final": "节点选择",
"auto_detect_interface": true
}
}
2.4 入站(inbounds)配置模板
1
2
3
4
5
6
7
8
9
10
11
{
"inbounds": [
{
"type": "tun",
"tag": "tun-in",
"address": "172.18.0.1/30",
"auto_route": true,
"strict_route": false
}
]
}
2.5 出站(outbounds)配置模板
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
{
"outbounds": [
{
"type": "direct",
"tag": "direct"
},
{
"type": "vless",
"tag": "visa.cn",
"server": "visa.cn",
"server_port": 443,
"uuid": "{your-uuid}",
"tls": {
"enabled": true,
"server_name": "{your-server-name}"
},
"transport": {
"type": "ws",
"path": "/?ed=2048",
"max_early_data": 2048,
"early_data_header_name": "Sec-WebSocket-Protocol",
"headers": {
"host": "{your-server-name}"
}
}
},
{
"type": "selector",
"tag": "节点选择",
"outbounds": ["优选域名", "direct"]
},
{
"type": "urltest",
"tag": "优选域名",
"outbounds": ["visa.cn"],
"interrupt_exist_connections": false
}
]
}
3.多协议出站配置模版
3.1 trojan
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
"outbounds": [
{
"type": "trojan",
"tag": "test-node-trojan",
"server": "{your-server-address}",
"server_port": 63814,
"password": "password",
"tls": {
"enabled": true,
"server_name": "bing.com",
"insecure": true,
"utls": {
"enabled": true,
"fingerprint": "chrome"
}
},
"multiplex": {
"enabled": true
}
}
]
}
3.2 hysteria2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
"outbounds": [
{
"type": "hysteria2",
"tag": "test-node-hysteria2",
"server": "{your-server-address}",
"server_port": 52072,
"up_mbps": 100,
"down_mbps": 100,
"password": "password",
"tls": {
"enabled": true,
"server_name": "bing.com",
"insecure": true
}
}
]
}
本文由作者按照
CC BY 4.0
进行授权
