-
Notifications
You must be signed in to change notification settings - Fork 3
/
config_custom.yaml
276 lines (237 loc) · 7.74 KB
/
config_custom.yaml
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
log:
level: info
file: "/etc/mosdns/mosdns.log"
# /etc/init.d/mosdns reload
api:
http: ":9091" # 在该地址启动 api 接口。
include:
plugins:
- tag: "hosts"
type: "hosts"
args:
files:
- "/etc/mosdns/rule/hosts.txt"
- tag: geosite_cn # 国内域名
type: domain_set
args:
files:
- "/etc/mosdns/rule/china_domain_list.txt"
- tag: cdnlist # 国内CDN
type: domain_set
args:
exps:
- "cloudflare.com"
- "microsoft.com"
- "msftconnecttest.com"
files:
- "/etc/mosdns/rule/apple_cn.txt"
- tag: "cache_0"
type: "cache"
args:
size: 1024 # 默认: 1024。
lazy_cache_ttl: 259200 # 默认: 0(禁用 lazy cache)。#建议值 86400(1天)~ 259200(3天)
dump_file: ./cache.dump
dump_interval: 7200 # (实验性) 自动保存间隔。
- tag: ecs_tw
type: ecs_handler
args:
forward: false
preset: 168.95.0.0
send: false
mask4: 16
# mask6: 40
- tag: ecs_us
type: ecs_handler
args:
forward: false
preset: 38.94.109.0
send: false
mask4: 24
# mask6: 40
- tag: "forward_local"
type: forward
args:
concurrent: 2
upstreams:
- addr: "211.138.180.2" # 运营商 DNS,自行修改
- addr: "211.138.180.3" # 运营商 DNS,自行修改
- tag: "forward_open"
type: forward
args:
concurrent: 2
upstreams:
- addr: "https://dns.alidns.com/dns-query"
dial_addr: "223.5.5.5"
enable_pipeline: true
- addr: "https://1.12.12.12/dns-query"
enable_pipeline: true
- tag: "forward_clash"
type: "forward"
args:
concurrent: 1
upstreams:
- addr: "127.0.0.1:7874"
- tag: "forward_remote"
type: "forward"
args:
concurrent: 2 # 并发数。每次请求随机选取 concurrent 个 upstreams 发送请求。
# 取最快返回的应答。超过 3 最多选 3 个。默认 1。
upstreams:
- addr: "https://162.159.36.1/dns-query"
enable_pipeline: true
enable_http3: true
- addr: "https://doh.opendns.com/dns-query"
dial_addr: "146.112.41.2"
enable_pipeline: true
- addr: "https://doh.openkiss.top/dns-query"
bootstrap: "211.138.180.2"
enable_pipeline: true
- tag: has_resp_sequence
type: sequence
args:
- matches:
- has_resp
exec: accept
- tag: remote_sequence_tw # 使用 TW ECS 查询优化 国外域名
type: sequence
args:
- exec: prefer_ipv4
- exec: $ecs_tw
- exec: $forward_remote
- exec: return
- tag: remote_sequence_us # 使用 US ECS 再次查询优化 Fastly CDN 结果
type: sequence
args:
- exec: query_summary fastly_remote
- exec: prefer_ipv4
- exec: $ecs_us
- exec: $forward_remote
- exec: jump has_resp_sequence
- tag: remote_sequence # forward 二选一
type: sequence
args:
- exec: prefer_ipv4
- exec: $forward_clash # mosdns前置:Dnsmasq → mosdns → clash
# - exec: $forward_remote # mosdns后置:Dnsmasq → clash → mosdns
- exec: accept
# IP 优选,需要定期修改,最好填写 2 - 4 个
- tag: blackhole_akamai # 替换部分 AKAMAI 域名 IP,详见 https://github.com/IrineSistiana/mosdns/discussions/489
type: sequence
args:
- exec: black_hole 23.202.34.132 23.2.16.10 23.219.172.61
- exec: query_summary best_akamai
- exec: ttl 3600-0
- exec: accept # 运行 black_hole 之后接受请求,不再进行后续判断
- tag: blackhole_cloudflare
type: sequence
args:
- exec: black_hole 104.19.103.248 104.18.61.44 104.19.61.230
- exec: query_summary cloudflare_best
- exec: ttl 3600-0
- exec: accept
- tag: blackhole_cloudfront
type: sequence
args:
- exec: black_hole 108.139.5.99 18.239.193.233 13.227.64.57
- exec: query_summary cloudfront_best
- exec: ttl 3600-0
- exec: accept
- tag: change_cdn_ip # https://github.com/XIU2/CloudflareSpeedTest/discussions/317
type: sequence
args:
- matches: # akamai cname 优选ip
- cname akamai.net
- qtype 1
- has_wanted_ans # 防止纯 IPV6 域名被替换
exec: jump blackhole_akamai
- matches: # 有些 AKAMAI 的域名不能直接替换 IP(没有绑定全证书)
- cname &./rule/akamai_domain_list.txt
exec: accept # 此处多加一次判断,接受所有 AKAMAI CDN 的 IP。
- matches: # cloudflare 优选ip
- qtype 1
- has_wanted_ans
- "resp_ip &./rule/cloudflare-ipv4.txt"
exec: jump blackhole_cloudflare
- matches: # cloudfront 优选ip
- qtype 1
- has_wanted_ans
- "resp_ip &./rule/cloudfront.txt"
exec: jump blackhole_cloudfront
- exec: return
- tag: reforward_fastly_remote
type: sequence
args:
- matches:
- "resp_ip &./rule/fastly.txt"
exec: jump remote_sequence_us
- exec: return
- tag: gfw_ip_sequence
type: sequence
args:
- matches: # 污染ip
- "resp_ip &./rule/gfw_ip_list.txt"
exec: goto remote_sequence
- exec: return
- tag: open_sequence
type: sequence
args:
- exec: prefer_ipv4
- exec: $forward_open
- exec: jump gfw_ip_sequence
- exec: jump reforward_fastly_remote
- exec: jump change_cdn_ip
- exec: accept # 有没有响应都终止,防止后续查询其他上游
- tag: default_sequence
type: sequence
args:
- exec: prefer_ipv4
- exec: $forward_open # 默认用国内,用来查询是否污染
- matches:
- "resp_ip &./rule/china_ip_list.txt"
exec: accept # 国内直接接受
- exec: jump gfw_ip_sequence
- exec: jump reforward_fastly_remote
- exec: jump remote_sequence_tw # mosdns前置:去掉 _tw 代表 国外ip全部走代理。
- exec: jump change_cdn_ip
- exec: jump has_resp_sequence
- tag: main
type: sequence
args:
- matches:
- qtype 65
exec: reject 3 # 屏蔽 QTYPE 65
- exec: $hosts
- exec: jump has_resp_sequence
- matches:
- qname &./rule/private.txt &./rule/block_list.txt #内网域名 & 黑名单
exec: reject 5 # 屏蔽内网域名
- matches:
- qname &./rule/white_list.txt # DDNS 和 其他白名单
exec: $forward_local # 运营商DNS
- exec: ttl 5-180
- exec: jump has_resp_sequence
- exec: $cache_0 # 下面的请求结果均进入缓存
- matches:
- qname &./rule/direct_list.txt
exec: jump remote_sequence_tw # 无污染DNS 1.不进行 IP 替换的域名,且不转发给clash
- exec: jump has_resp_sequence
- matches:
- qname &./rule/google_cn.txt &./rule/wall_list.txt # wall_list手动创建
exec: jump remote_sequence # 适用于被墙/被污染/ 2.尚未移出geosite_cn列表的,提前走代理
- matches:
- qname $geosite_cn $cdnlist &./rule/akamai_domain_list.txt
exec: jump open_sequence # 国内域名 & 3.令存在于gfwlist列表中的部分国内cdn,提前走直连
- matches:
- qname &./rule/proxy_domain_list.txt # GFW 域名直接请求clash
exec: jump remote_sequence
- exec: jump default_sequence
- tag: udp_server
type: udp_server
args:
entry: main
listen: ":5335"
- tag: tcp_server
type: tcp_server
args:
entry: main
listen: ":5335"