2023-02-25 02:38:21 +08:00
|
|
|
# DNS
|
|
|
|
|
2023-03-15 12:55:33 +08:00
|
|
|
dae will intercept all UDP traffic to port 53 and sniff DNS. Here gives some examples and templates for DNS configuration.
|
|
|
|
|
2024-11-02 17:46:51 +08:00
|
|
|
# Schema
|
|
|
|
|
|
|
|
DoH3
|
|
|
|
|
|
|
|
```
|
|
|
|
h3://<host>:<port>/<path>
|
|
|
|
http3://<host>:<port>/<path>
|
|
|
|
|
|
|
|
default port: 443
|
|
|
|
default path: /dns-query
|
|
|
|
```
|
|
|
|
|
|
|
|
DoH
|
|
|
|
|
|
|
|
```
|
|
|
|
https://<host>:<port>/<path>
|
|
|
|
|
|
|
|
default port: 443
|
|
|
|
default path: /dns-query
|
|
|
|
```
|
|
|
|
|
|
|
|
DoT
|
|
|
|
|
|
|
|
```
|
|
|
|
tls://<host>:<port>
|
|
|
|
|
|
|
|
default port: 853
|
|
|
|
```
|
|
|
|
|
|
|
|
DoQ
|
|
|
|
|
|
|
|
```
|
|
|
|
quic://<host>:<port>
|
|
|
|
|
|
|
|
default port: 853
|
|
|
|
```
|
|
|
|
|
|
|
|
UDP
|
|
|
|
|
|
|
|
```
|
|
|
|
udp://<host>:<port>
|
|
|
|
|
|
|
|
default port: 53
|
|
|
|
```
|
|
|
|
|
|
|
|
TCP
|
|
|
|
|
|
|
|
```
|
|
|
|
tcp://<host>:<port>
|
|
|
|
|
|
|
|
default port: 53
|
|
|
|
```
|
|
|
|
|
|
|
|
TCP and UDP
|
|
|
|
|
|
|
|
```
|
|
|
|
tcp+udp://<host>:<port>
|
|
|
|
|
|
|
|
default port: 53
|
|
|
|
```
|
|
|
|
|
2023-03-15 12:55:33 +08:00
|
|
|
## Examples
|
2023-02-25 02:38:21 +08:00
|
|
|
|
|
|
|
```shell
|
|
|
|
dns {
|
2023-05-30 22:10:32 +08:00
|
|
|
# For example, if ipversion_prefer is 4 and the domain name has both type A and type AAAA records, the dae will only
|
|
|
|
# respond to type A queries and response empty answer to type AAAA queries.
|
2023-04-10 01:11:37 +08:00
|
|
|
ipversion_prefer: 4
|
|
|
|
|
2023-05-30 22:10:32 +08:00
|
|
|
# Give a fixed ttl for domains. Zero means that dae will request to upstream every time and not cache DNS results
|
|
|
|
# for these domains.
|
|
|
|
fixed_domain_ttl {
|
|
|
|
ddns.example.org: 10
|
|
|
|
test.example.org: 3600
|
|
|
|
}
|
|
|
|
|
2023-02-25 02:38:21 +08:00
|
|
|
upstream {
|
2024-11-02 17:46:51 +08:00
|
|
|
# Scheme list: tcp, udp, tcp+udp, https, tls, http3, h3, quic, details see above Schema.
|
2023-02-25 02:38:21 +08:00
|
|
|
# If host is a domain and has both IPv4 and IPv6 record, dae will automatically choose
|
|
|
|
# IPv4 or IPv6 to use according to group policy (such as min latency policy).
|
|
|
|
# Please make sure DNS traffic will go through and be forwarded by dae, which is REQUIRED for domain routing.
|
|
|
|
# If dial_mode is "ip", the upstream DNS answer SHOULD NOT be polluted, so domestic public DNS is not recommended.
|
|
|
|
|
|
|
|
alidns: 'udp://dns.alidns.com:53'
|
2024-09-29 16:42:15 +08:00
|
|
|
googledns: 'tcp+udp://dns.google:53'
|
2024-11-02 17:46:51 +08:00
|
|
|
|
|
|
|
# alih3: 'h3://dns.alidns.com:443'
|
|
|
|
# alih3_path: 'h3://dns.alidns.com:443/dns-query'
|
|
|
|
# alihttp3: 'http3://dns.alidns.com:443'
|
|
|
|
# alihttp3_path: 'http3://dns.alidns.com:443/dns-query'
|
|
|
|
# ali_quic: 'quic://dns.alidns.com:853'
|
|
|
|
|
2024-11-03 21:38:38 +08:00
|
|
|
# h3_custom_path: 'h3://dns.example.com:443/custom-path'
|
|
|
|
# http3_custom_path: 'http3://dns.example.com:443/custom-path'
|
2024-11-02 17:46:51 +08:00
|
|
|
|
|
|
|
# ali_doh: 'https://dns.alidns.com:443'
|
|
|
|
# ali_dot: 'tls://dns.alidns.com:853'
|
|
|
|
|
2024-11-03 21:38:38 +08:00
|
|
|
# doh_custom_path: 'https://dns.example.com:443/custom-path'
|
2023-02-25 02:38:21 +08:00
|
|
|
}
|
|
|
|
# The routing format of 'request' and 'response' is similar with section 'routing'.
|
2023-07-09 17:31:47 +08:00
|
|
|
# See https://github.com/daeuniverse/dae/blob/main/docs/en/configuration/routing.md
|
2023-03-17 04:41:46 +08:00
|
|
|
routing {
|
2023-03-27 12:45:10 +08:00
|
|
|
# According to the request of dns query, decide to use which DNS upstream.
|
|
|
|
# Match rules from top to bottom.
|
2023-03-17 04:41:46 +08:00
|
|
|
request {
|
2023-03-31 15:46:53 +08:00
|
|
|
# Built-in outbounds in 'request': asis, reject.
|
2023-03-17 04:41:46 +08:00
|
|
|
# You can also use user-defined upstreams.
|
2023-02-25 02:38:21 +08:00
|
|
|
|
2023-03-17 04:41:46 +08:00
|
|
|
# Available functions: qname, qtype.
|
2023-02-25 02:38:21 +08:00
|
|
|
|
2023-03-17 04:41:46 +08:00
|
|
|
# DNS request name (omit suffix dot '.').
|
2023-03-31 15:46:53 +08:00
|
|
|
qname(geosite:category-ads-all) -> reject
|
2023-07-01 12:05:03 +08:00
|
|
|
qname(geosite:google@cn) -> alidns # Also see: https://github.com/v2fly/domain-list-community#attributes
|
2023-03-17 04:41:46 +08:00
|
|
|
qname(suffix: abc.com, keyword: google) -> googledns
|
|
|
|
qname(full: ok.com, regex: '^yes') -> googledns
|
|
|
|
# DNS request type
|
|
|
|
qtype(a, aaaa) -> alidns
|
|
|
|
qtype(cname) -> googledns
|
2024-12-19 07:46:39 +00:00
|
|
|
# disable ECH to avoid affecting traffic split
|
|
|
|
qtype(https) -> reject
|
2023-03-17 04:41:46 +08:00
|
|
|
# If no match, fallback to this upstream.
|
|
|
|
fallback: asis
|
|
|
|
}
|
2023-03-27 12:45:10 +08:00
|
|
|
# According to the response of dns query, decide to accept or re-lookup using another DNS upstream.
|
|
|
|
# Match rules from top to bottom.
|
2023-03-17 04:41:46 +08:00
|
|
|
response {
|
2023-03-31 15:46:53 +08:00
|
|
|
# Built-in outbounds in 'response': accept, reject.
|
2023-03-17 04:41:46 +08:00
|
|
|
# You can use user-defined upstreams.
|
2023-02-25 02:38:21 +08:00
|
|
|
|
2023-03-17 04:41:46 +08:00
|
|
|
# Available functions: qname, qtype, upstream, ip.
|
|
|
|
# Accept the response if the request is sent to upstream 'googledns'. This is useful to avoid loop.
|
|
|
|
upstream(googledns) -> accept
|
|
|
|
# If DNS request name is not in CN and response answers include private IP, which is most likely polluted
|
2023-05-21 00:41:44 +08:00
|
|
|
# in China mainland. Therefore, resend DNS request to 'googledns' to get correct result.
|
2023-10-21 03:04:13 -05:00
|
|
|
ip(geoip:private) && !qname(geosite:cn) -> googledns
|
2023-03-17 04:41:46 +08:00
|
|
|
fallback: accept
|
|
|
|
}
|
2023-02-25 02:38:21 +08:00
|
|
|
}
|
2023-05-21 00:41:44 +08:00
|
|
|
|
2023-02-25 02:38:21 +08:00
|
|
|
}
|
|
|
|
```
|
2023-03-15 12:55:33 +08:00
|
|
|
|
|
|
|
## Templates
|
|
|
|
|
|
|
|
```shell
|
2023-03-16 14:42:08 +08:00
|
|
|
# Use alidns for China mainland domains and googledns for others.
|
2023-03-15 12:55:33 +08:00
|
|
|
dns {
|
|
|
|
upstream {
|
2024-09-29 16:42:15 +08:00
|
|
|
googledns: 'tcp+udp://dns.google:53'
|
2023-03-15 12:55:33 +08:00
|
|
|
alidns: 'udp://dns.alidns.com:53'
|
|
|
|
}
|
2023-03-17 00:43:24 +08:00
|
|
|
routing {
|
2023-03-27 12:45:10 +08:00
|
|
|
# According to the request of dns query, decide to use which DNS upstream.
|
|
|
|
# Match rules from top to bottom.
|
2023-03-17 00:43:24 +08:00
|
|
|
request {
|
2023-03-27 12:45:10 +08:00
|
|
|
# Lookup China mainland domains using alidns, otherwise googledns.
|
2023-03-17 00:43:24 +08:00
|
|
|
qname(geosite:cn) -> alidns
|
2023-03-27 12:45:10 +08:00
|
|
|
# fallback is also called default.
|
2023-03-17 00:43:24 +08:00
|
|
|
fallback: googledns
|
|
|
|
}
|
2023-03-15 12:55:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
```shell
|
2023-03-16 14:42:08 +08:00
|
|
|
# Use alidns for all DNS queries and fallback to googledns if pollution result detected.
|
2023-03-15 12:55:33 +08:00
|
|
|
dns {
|
|
|
|
upstream {
|
2024-09-29 16:42:15 +08:00
|
|
|
googledns: 'tcp+udp://dns.google:53'
|
2023-03-15 12:55:33 +08:00
|
|
|
alidns: 'udp://dns.alidns.com:53'
|
|
|
|
}
|
2023-03-17 00:43:24 +08:00
|
|
|
routing {
|
2023-03-27 12:45:10 +08:00
|
|
|
# According to the request of dns query, decide to use which DNS upstream.
|
|
|
|
# Match rules from top to bottom.
|
2023-03-17 00:43:24 +08:00
|
|
|
request {
|
2023-03-27 12:45:10 +08:00
|
|
|
# fallback is also called default.
|
2023-03-17 00:43:24 +08:00
|
|
|
fallback: alidns
|
|
|
|
}
|
2023-03-27 12:45:10 +08:00
|
|
|
# According to the response of dns query, decide to accept or re-lookup using another DNS upstream.
|
|
|
|
# Match rules from top to bottom.
|
2023-03-17 00:43:24 +08:00
|
|
|
response {
|
2023-03-27 12:45:10 +08:00
|
|
|
# Trusted upstream. Always accept its result.
|
2023-03-17 00:43:24 +08:00
|
|
|
upstream(googledns) -> accept
|
2023-03-27 12:45:10 +08:00
|
|
|
# Possibly polluted, re-lookup using googledns.
|
2023-10-21 03:04:13 -05:00
|
|
|
ip(geoip:private) && !qname(geosite:cn) -> googledns
|
2023-03-27 12:45:10 +08:00
|
|
|
# fallback is also called default.
|
2023-03-17 00:43:24 +08:00
|
|
|
fallback: accept
|
|
|
|
}
|
2023-03-15 12:55:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|