DNS
DnsConfig, servers, and hijacking
DNS is configured in ServerConfig.dns (DnsConfig). Schema definition: protos/proto/vx/dns/dns.proto.
dnsServers defines named upstreams; concurrentDnsServers / serialDnsServers can combine multiple upstreams into new named servers; internalResolver and requestDomainResolver reference these servers by name. dnsHijack selects the upstream for hijacked DNS queries.
DnsConfig
recordsStatic domain records answered by the local static server before querying other upstreams.
recordStringsStatic records in standard DNS RR text format (e.g. www.example.com. 3600 IN A 192.0.2.1), equivalent to records and convenient for pasting full record lines.
dnsServersNamed DNS upstream definitions. Each must have a unique name and one server type (type oneof).
concurrentDnsServersCombine multiple defined DNS servers into a new named server by querying them in parallel.
serialDnsServersCombine multiple defined DNS servers into a new named server by trying them in order.
Record
domainHostname
ipStatic IP answers. IPv4 produces A records; IPv6 produces AAAA records.
proxiedDomainWhen non-empty, produce a CNAME to proxiedDomain for this domain instead of returning ip directly.
Resolver
Resolvers reference DnsServerConfig, ConcurrentDnsServer, or SerialDnsServer by name from dnsServers. Multiple names are tried serially in order.
dnsServersList of named DNS servers to use
intervalWait time between queries when trying serially (seconds)
nameResolver name
ConcurrentDnsServer
dnsServersNames of DNS servers to query in parallel
nameName of the combined server, referenced by Resolver.dnsServers and DnsRuleConfig.dnsServerName
SerialDnsServer
dnsServersNames of DNS servers to try in order
intervalHow long to wait before trying the next server after the current one fails (seconds)
nameName of the combined server
DnsServerConfig
Each server has a unique name.
Only one of plainDnsServer, tlsDnsServer, dohDnsServer, quicDnsServer, fakeDnsServer,
goDnsServer, or emptyDnsServer may be set.
nameServer name; referenced by resolvers, combined servers, and DNS rules
Do not use hijack as a name
clientIpClient IP sent in EDNS Client Subnet (ECS)
cacheDurationAnswer cache duration (seconds). When 0, the minimum TTL from the answer is used.
ipTagsKeep only answer addresses that fall within these geo IP sets; other IPs are discarded
PlainDnsServer
addressesUpstream addresses in host:port format (typically port 53)
useDefaultDnsWhen true, use DNS servers on the system default interface; updates automatically when interface DNS changes. Falls back to addresses when no system DNS is available.
TlsDnsServer
addressesDoT upstream addresses in host:port format (typically port 853)
DohDnsServer
urlDoH endpoint URL (e.g. https://dns.google/dns-query)
QuicDnsServer
addressDoQ upstream address (host:port)
FakeDnsServer
poolConfigsFake IP address pool configuration. Avoid configuring multiple overlapping pools for the same IP version (IPv4 / IPv6).
PoolConfig
cidrCIDR for the fake IP pool (e.g. 198.18.0.0/15)
lruSizeLRU capacity for domain → fake IP mappings in the pool
GoDnsServer
Uses the operating system / Go default resolution path. Its traffic does not go through the dispatcher and is sent directly. This type is typically used on the server side.
EmptyDnsServer
Always returns an empty resolution.
DnsHijackConfig
dnsRulesRoute hijacked DNS requests to a specified dnsServerName by domain, set, and query type. Rules are matched in order.
When this configuration is present, a DNS server named hijack is added automatically. A dns outbound is also added so you can specify the dns outbound in routing rules to hijack DNS traffic.
DnsRuleConfig
dnsServerNameTarget DnsServerConfig.name (or combined server name)
ruleNameLabel for debugging and display
DnsType
DNS query type enum defined in proto, including DnsType_A, DnsType_AAAA, DnsType_CNAME, DnsType_HTTPS, DnsType_ANY, etc.
Example
Static records + direct DoH + hijack rules:
{
"dns": {
"records": [
{ "domain": "internal.example", "ip": ["10.0.0.1"] }
],
"dnsServers": [
{
"name": "doh",
"dohDnsServer": { "url": "https://dns.google/dns-query" }
}
],
"internalResolver": {
"dnsServers": ["doh"]
},
"requestDomainResolver": {
"dnsServers": ["doh"]
},
"dnsHijack": {
"enableFakeDns": true,
"dnsRules": [
{
"dnsServerName": "doh",
"domainTags": ["gfw"],
"includedTypes": ["DnsType_A", "DnsType_AAAA"],
"ruleName": "proxy-dns"
}
]
}
}
}Related
- Geo —
domainTags,ipTagson rules and servers - Router —
fakeIpand domain resolution rules - Dialer factory —
useInternalResolver