log:
level: info
file: ./log.log
include: []
data_providers:
- tag: geoip.dat
file: ./geoip.dat
# - tag: oisd_dbl_basic
# file: ./oisd_dbl_basic.txt
servers:
- exec: main_sequence # 本服务器运行插件的 tag 。
timeout: 5 # 请求处理超时时间。单位: 秒。默认: 5 。
listeners: # 监听设置
- protocol: udp
addr: :53
- protocol: tcp
addr: :53
- protocol: dot
addr: :853
cert: '/ssl-cert/
XXXXXX.com/cert.pem' # `dot`, `doh` 必需。PEM 格式的证书文件。
key: '/ssl-cert/
XXXXXX.com/key.pem' # `dot`, `doh` 必需。PEM 格式的密钥文件。
- protocol: doh
addr: :443
cert: '/ssl-cert/
XXXXXX.com/cert.pem' # `dot`, `doh` 必需。PEM 格式的证书文件。
key: '/ssl-cert/
XXXXXX.com/key.pem' # `dot`, `doh` 必需。PEM 格式的密钥文件。
url_path: '/dns-query' # url 路径。适用于 `doh`, `http`。如果为空,则任意路径的请求都能被处理。
get_user_ip_from_header: 'X-Forwarded-For' # 适用于 `doh`, `http`。尝试从反向代理的 HTTP 头获取用户 IP 。
plugins:
- tag: mem_cache
type: cache
args:
size: 10240 # 内存缓存大小。单位: 条。默认: 1024 。
lazy_cache_ttl: 86400 # lazy cache 生存时间。单位: 秒。默认: 0 (禁用 lazy cache)。
# RFC 8767 的建议值 86400 (1 天) ~ 259200 (3 天)
lazy_cache_reply_ttl: 30 # 返回过期应答的 TTL 。默认 30 (RFC 8767 的建议值)。
- tag: query_is_ad_domain
type: query_matcher
args:
domain:
- 'provider:oisd_dbl_basic'
- tag: forward_china
type: fast_forward
args:
upstream:
- addr: https://1.12.12.12/dns-query
trusted: true
- addr: https://223.5.5.5/dns-query
trusted: true
- tag: forward_overseas
type: fast_forward
args:
upstream:
- addr:
https://doh.opendns.com/dns-query trusted: true
- addr:
https://dns.quad9.net/dns-query trusted: true
- addr:
https://dns.google/dns-query trusted: true
enable_pipeline: true
enable_http3: true
- addr:
https://cloudflare-dns.com/dns-query trusted: true
enable_pipeline: true
enable_http3: true
- tag: response_has_china_ip
type: response_matcher
args:
ip:
- 'provider:geoip.dat:cn'
- tag: main_sequence
type: sequence
args:
exec:
# - _no_ecs # 删除请求和应答中的 ECS
- mem_cache # 运行缓存插件
# - if: query_is_ad_domain
# exec:
# - _new_nxdomain_response # 生成 NXDOMAIN 应答
# - _return
- _prefer_ipv4 # 优先使用 ipv4
# 域名用 IP 分流。原理类似 ChinaDNS ,但更稳定。
- primary:
- forward_china # 获取 china 服务器应答。
- if: "! response_has_china_ip" # 返回 非国内 ip 则丢弃
exec:
- _drop_response
secondary:
- forward_overseas # 获取 overseas 服务器应答。
fast_fallback: 1000 # 快速 fallback 触发阈值。单位: 毫秒。默认: 0 ,禁用快速 fallback 。可省略。
always_standby: true # 快速 fallback secondary 始终待命。可省略。