DNS
As of build 427 Loon supports four kinds of DNS lookup:
- standard UDP queries
- DNS-over-HTTPS
- DNS-over-QUIC
- DNS-over-HTTP3
Configuration
[General]
# DNS servers; system means the DNS server provided by the system
dns-server = system,119.29.29.29,223.5.5.5
# DoH servers, plain URLs, separate several with commas
doh-server = https://example.com/dns-query
# DoQ servers, prefixed with quic://, separate several with commas, default port 784
doq-server = quic://example.com:784
# DoH3 servers, plain URLs, separate several with commas
doh3-server = h3://example.com/dns-queryLookup logic
Loon splits every DNS lookup into two categories: ordinary DNS queries and encrypted DNS queries (DoH/DoQ/DoH3). When encrypted and ordinary servers are both configured, only encrypted queries are made. The query is sent to every reachable server concurrently and the fastest response wins.
DNS cache
Loon designed two DNS caches. The first was an in-memory cache (removed in 3.1.5). A 100-entry LRU cache is used (raised to 200 on iOS 15 and later); it lives for the duration of the Loon process and is wiped when Loon stops. The second was an on-disk cache, pruned automatically from the TTL, and could be switched off (removed in 3.1.5).
Lookup and cache-hit logic
Before resolving a domain, the in-memory cache is consulted. On a hit its answer is used directly; if the cached IP has passed its TTL, one lookup is made and the cache is updated with the result. On a miss the on-disk cache was consulted next, with the same hit logic as the memory cache (removed in 3.1.5). With no cached entry, the configured DNS servers are queried concurrently, the first answer is used and the cache is updated.
Fallback
When an encrypted DNS query fails, the lookup falls back to ordinary DNS. This can be switched off on the DNS server screen in the app.
