Files
2026-05-27 09:55:37 +08:00

2.8 KiB
Raw Permalink Blame History

DNS 配置

对应 settings.toml[dns][[dns.rules]]

设置 UI 默认值 可选值 作用 什么时候修改
query_strategy 显示 UseIPv4 空 / UseIP / UseIPv4 / UseIPv6 写入 dns.queryStrategy。空值表示不写该字段。 IPv6 可用时可改 UseIP / UseIPv6IPv6 不稳定保持 UseIPv4
disable_fallback 显示 false bool true 时写入 dns.disableFallback 想严格按 DNS 规则解析时开启;解析容错下降。
local_dns_listen 显示 true bool 控制是否生成本地 DNS 入站。 redirect 透明代理下需要接管宿主机 DNS 时开启。
hosts 隐藏 {courier.push.apple.com = ["1-courier.push.apple.com"]} 字典 写入 dns.hosts 需要固定域名解析时手改。
rules 显示 见下表 `server domains outbound`
antipollution 显示 closed closed / none / dnsforward / doh / advanced 预留字段,当前不直接影响 Xray JSON。 当前一般不改。
special_mode 显示 none none / supervisor / fakedns 预留字段,当前不直接影响 Xray JSON。 当前一般不改。

默认 DNS 规则

server domains outbound 作用
localhost geosite:private direct 私有域名走本地 DNS。
223.5.5.5 geosite:cn direct 中国域名走国内 DNS。
8.8.8.8 proxy 兜底 DNS 走代理。

DNS 规则字段

字段 默认值 可选值 作用
server localhost、IP、host:port、DoH URL DNS 服务器地址。
domains "" 换行/规则字符串 非空时只匹配这些域名规则;空表示默认 DNS。
outbound direct direct / proxy / block / 自定义 tag 连接该 DNS 服务器自身时使用的出口。

本地 DNS 入站

条件 生成结果
local_dns_listen = truetransparent.mode != closetransparent.type = redirect 生成 dns-in
同时 inbounds.port_sharing = true 额外生成 dns-in-local0.0.0.0:53
其它情况 不生成本地 DNS 入站。

生成影响

行为 说明
domains 的 DNS rule 生成 {address, domains} server。
domains 的 DNS rule 插入到 dns.servers 前部,作为默认 DNS。
DNS 服务器不是 localhost 生成一条 routing rule,按 outbound 连接 DNS 服务器。
节点服务器是域名 额外加入 DNS lookup domains,避免代理节点域名解析走错。