请配合luci-app-mosdns包的自定义配置食用,本配置修改自官方配置luci-app-mosdns包的配置,兼顾了IPv6的功能,但不会碰到那种客户端解析IPv6优先导致超时连接的恶心情况。
使用时注意一下几点,避免踩坑:
- 端口号如果不是5335的需要自行修改。
- 配置里的DNS可以使用UDP、DOH、DOT连接,使用DOH和DOT时第一个DNS尽量使用IP,如果一定要使用域名,请参考官方配置对应的IP地址,因为MosDNS可能不能直接解析域名。
- 与Passwall的配合使用,需要将Passwall的远程DNS设置为
127.0.0.1:5335或者你的自定义端口号。 - 保证配置中提到的文件可用,除了luci-app-mosdns包,还需要安装v2ray,安装了Passwall的会自动安装v2ray依赖。
以下是/etc/mosdns/cus_config.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
| log:
level: error
file: /tmp/mosdns.txt
plugin:
- tag: main_server
type: server
args:
entry:
- _no_ecs
- lazy_cache
- _prefer_ipv4
- _single_flight
- main_sequence
server:
- protocol: udp
addr: "127.0.0.1:5335"
- protocol: tcp
addr: "127.0.0.1:5335"
- tag: main_sequence
type: sequence
args:
exec:
- query_is_hosts_domain
- query_is_redirect_domain
- if:
- query_is_whitelist_domain
exec:
- forward_local
- _return
- if:
- query_is_blocklist_domain
- query_is_ad_domain
- qtype65
exec:
- _block_with_nxdomain
- _return
- if:
- query_is_local_domain
- "!_query_is_common"
exec:
- forward_local
- _return
- if:
- query_is_non_local_domain
exec:
- forward_remote
- _return
- primary:
- forward_local
- if:
- "!response_has_local_ip"
exec:
- _drop_response
secondary:
- forward_remote
fast_fallback: 150
always_standby: true
- tag: forward_local
type: fast_forward
args:
upstream:
- addr: https://1.12.12.12/dns-query
- addr: https://223.5.5.5/dns-query
- tag: query_is_whitelist_domain
type: query_matcher
args:
domain:
- "ext:./whitelist.txt"
- tag: query_is_blocklist_domain
type: query_matcher
args:
domain:
- "ext:/etc/mosdns/rule/blocklist.txt"
- tag: query_is_hosts_domain
type: hosts
args:
hosts:
- "ext:/etc/mosdns/rule/hosts.txt"
- tag: query_is_redirect_domain
type: redirect
args:
rule:
- "ext:/etc/mosdns/rule/redirect.txt"
- tag: forward_remote
type: fast_forward
args:
upstream:
- addr: https://8.8.8.8/dns-query
- addr: https://208.67.222.2/dns-query
- addr: https://doh.dns.sb/dns-query
- tag: lazy_cache
type: cache
args:
size: 512000
lazy_cache_ttl: 259200
- tag: query_is_local_domain
type: query_matcher
args:
domain:
- "ext:/usr/share/v2ray/geosite.dat:cn"
- "ext:/usr/share/v2ray/geosite.dat:apple-cn"
- tag: query_is_non_local_domain
type: query_matcher
args:
domain:
- "ext:/usr/share/v2ray/geosite.dat:geolocation-!cn"
- tag: response_has_local_ip
type: response_matcher
args:
ip:
- "ext:/usr/share/v2ray/geoip.dat:cn"
- tag: query_is_ad_domain
type: query_matcher
args:
domain:
- "ext:./serverlist.txt"
- tag: qtype65
type: query_matcher
args:
qtype: [65]
|