Encrypted DNS
The server answers DNS over TLS (DoT) on port 853, which is what Android calls Private DNS. A phone set to use it gets its answers through an encrypted connection, at home and away from it. You give the server a certificate and the addresses to listen on, and you choose which clients it resolves names for. Nobody on the path between the phone and the server can then read the names the phone asks for, or answer in the server’s place. The server itself still sees each name, and so does the upstream it asks.
The server also answers DNS over HTTPS (DoH), which browsers and Apple devices speak. A DoH
client asks a URL on port 443, such as https://dns.example.net/dns-query, rather than a host
name on port 853. The server can hold the TLS session itself, or sit behind a reverse proxy that
already serves your other sites. “DNS over HTTPS” below sets up both.
The server answers DNS over QUIC (DoQ) and DNS over HTTPS on HTTP/3 (DoH3) as well. Both run over UDP, and a lost packet does not hold up every query behind it, as it does on TCP. “DNS over QUIC and HTTP/3” below sets them up.
The server can also ask its own upstreams over TLS, HTTPS or QUIC, so the names your house asks leave it encrypted. “Encrypted forwarders” below sets that up.
This page sets up DoT end to end first: three settings and a choice of clients, a certificate from certbot, the forward on your router, and a phone. Each setting has its row in “DNS over TLS” in Configuration.
What you need
Section titled “What you need”- A host name that resolves to your home address from outside, such as
dns.example.net. A phone checks that the certificate names the host name it was given, so an address alone does not work. - A certificate for that name, and its private key, as two PEM files. certbot makes both, and the next part shows how. A PKCS #12 file serves too, as “A certificate from a PKCS #12 file” below shows. The server can also get the certificate itself, as “A certificate from ACME” below shows. On a private network with no name in public DNS, the server can make one of its own, as “A certificate that the server makes” below shows. A client then trusts it only where you set it by hand.
- Port 853 over TCP forwarded from your router to the machine that runs the server.
The settings
Section titled “The settings”All four go in node.toml, because a certificate names one machine. The first three turn DoT on.
The fourth is the choice of clients, and its default holds your own networks alone. The example
opens it to everybody, which a phone away from home needs. “What a stranger gets” below says what
that costs before you copy it.
tls_listen = ["192.168.1.2:853"]tls_certificate_file = "/etc/letsencrypt/live/dns.example.net/fullchain.pem"tls_private_key_file = "/etc/letsencrypt/live/dns.example.net/privkey.pem"encrypted_allow_recursion = ["0.0.0.0/0", "::/0"]tls_listen names an address of this machine, as listen does. Use the address your router
forwards to. A TLS address cannot use port 53, which carries plain DNS. If you leave the port out, it is 853.
The two files are read where they are. The server never copies the key, so a backup of the server does not hold it. Each path must be absolute.
encrypted_allow_recursion says which clients over TLS the server resolves names for. A phone away from home arrives from an address that nobody knows in advance, so the list has
to hold everybody. That list does not touch plain DNS on port 53, which keeps reading
allow_recursion. “What a stranger gets” below says what the open list gives away.
Save the file. The server applies the change at once, and the address starts to answer. A file it refuses changes nothing, and the refusal names the setting.
A certificate from certbot
Section titled “A certificate from certbot”certbot gets a certificate from Let’s Encrypt. Any way that proves you own the name works. A DNS challenge needs no open port, which suits a server that answers only on 853.
sudo certbot certonly --manual --preferred-challenges dns -d dns.example.netcertbot keeps the files under /etc/letsencrypt/live/dns.example.net/, readable by root alone. The
server runs as the tadoru account. Give that group read access to the key, and a way through the
four directories on the path to it:
cd /etc/letsencryptsudo chgrp tadoru live archive live/dns.example.net archive/dns.example.netsudo chmod 0750 live archive live/dns.example.net archive/dns.example.netsudo chgrp tadoru /etc/letsencrypt/archive/dns.example.net/privkey*.pemsudo chmod 0640 /etc/letsencrypt/archive/dns.example.net/privkey*.pemThe files under live/ are links into archive/, and the server judges the file a link points
to. Each file must belong to root or to tadoru. The key must give nothing to other users and no
write to its group, so 0640 passes. The certificate must give write to nobody but its owner.
A file that breaks a rule refuses the change, and A certificate file the server will not take
lists every reason.
When certbot renews the certificate, it gives the new key the group and the group mode of the old one. certbot does this from version 0.29.0 on.
A renewal serves within about a minute, with nothing to restart. Every 30 seconds, the server looks
at the metadata of both files, after the links: the device, the inode, the size, and the time of
the last change. It reads the files only where one of them moved. A move of a link to a new file in
archive/ counts, and so does a chmod.
- certbot replaces the key, and then the certificate. Where the server looks between the two, it
finds a key that is not the key of the certificate. The log shows the warning
the TLS certificate did not reloadonce, and the old certificate keeps serving. The server reads both files again at each look, and the pair serves at the look after the certificate moved. - A file that is still wrong warns once, not at each look. A new change of the file warns again.
- A file with the same content changes nothing, so no client pays a full handshake for it.
- A change of
node.tomlreads the files itself. Where certbot moved them while that change was applied, the next look reads them again. - The server also reads both files every hour, for a file system that does not move the time of a change.
In a container
Section titled “In a container”Mount the directory that holds the files, read-only, at the same path, and let the container’s user
read the key through its group. A host that runs only the container has no tadoru group. Make one
first with sudo groupadd tadoru, then run the four commands above.
docker run -d --name tadoru --restart unless-stopped \ --network host --cap-add NET_BIND_SERVICE \ --group-add "$(getent group tadoru | cut -d: -f3)" \ -v /etc/letsencrypt:/etc/letsencrypt:ro -v ./data:/data tadoru:localThe container runs as uid 65532, so the owner rule passes through root, which owns the files. The
--group-add gives that user the group you granted above. Port 853 is below 1024, so it needs the
same right as port 53. The binary in the image carries it, and --cap-add keeps it allowed where a
setup drops the rest.
A certificate from a PKCS #12 file
Section titled “A certificate from a PKCS #12 file”Windows and many routers export a certificate and its key as one PKCS #12 file, often named
.p12 or .pfx, under a password. tls_pkcs12_file names that file in place of
tls_certificate_file and tls_private_key_file. The password is a secret of the node: it is
never in node.toml, and no route gives it back.
-
Put the file where the server reads it, owned by root or by
tadoru, with nothing for other users and no write for its group:Terminal window sudo install -o root -g tadoru -m 0640 server.p12 /etc/tadoru/tls/server.p12 -
Set the password before you name the file. A revision whose file the password does not open is refused. The command asks for the value with the echo off, so it stays out of the shell history, and it goes to the running server over the socket:
Terminal window sudo -u tadoru tadoru secret set tls_pkcs12_passwordWith the server stopped, the same command writes the file itself. An admin can also send
PUT /api/node/secrets/tls_pkcs12_passwordwith a token, as Accounts says. -
Name the file in
node.toml:tls_listen = ["192.168.1.2:853"]tls_pkcs12_file = "/etc/tadoru/tls/server.p12"
The server reads the file where it is, and checks its MAC with the password before anything else. It takes the defaults of OpenSSL 3, and of OpenSSL 1.1 with its key under Triple DES. A PKCS #12 file the server will not take lists each file that it refuses and how to write it again.
A new file at the path serves at the next look, as a renewed PEM file does. A new password reads the file again at once: the server tries the value on the file first, and a value that does not open it is refused with 422, so the old one stays. Where the file and the password both change, set the password after the new file is in place. The answer says what the reload did, as A change of a secret of the node that is refused explains.
A certificate that the server makes
Section titled “A certificate that the server makes”On a node with no other way to get a certificate, the server can make one of its own:
tls_listen = ["192.168.1.2"]console_listen = ["192.168.1.2:5343"]tls_self_signed = trueThe certificate names tls_server_name where it is set, localhost, and each address of the
encrypted listeners and of the doors of the console and the API. It signs itself, with a key of
ECDSA P-256, and lasts 397 days. It lives in pki/self-signed/ of the state root, which a backup
carries and a backup with no passphrase refuses.
The server makes a new one, with the same key, in three cases:
- 30 days before the end of the old one. The server looks at each start and every hour.
- At a revision that changes the names. The revision serves the new one from its commit. Where something holds the store at that moment, such as a backup, the old certificate keeps serving a short time after the revision is in force, with the old names. The server tries again every minute, and a backup that holds the store at each try delays it each time.
- Once the clock is trusted, after a start with no trusted clock: a time client set it, or the
grace window of the clock ended. A board with no clock of
its own starts that way. The first certificate then starts at the date of the build, so a client
with a true clock does not find it from the future, and its subject says
dates from the clock floor. The server cannot renew such a certificate until the clock is trusted, and the health says so as the end comes near.
Where the store is busy at the first revision that turns it on, no certificate serves until the
server can take the store, and the health says renewal_failing with the reason.
Each new certificate gets a new fingerprint, so a browser that accepted the old one warns again.
The key stays, so a pin of the key survives. tadoru health gives both, over the socket that no
one on the network can reach:
$ tadoru healthok, revision 12, self-signed certificate ok, SHA-256 3F:9A:...:C1, key SHA-256 mN2v...Ps8=Compare the first with the SHA-256 fingerprint that the browser shows at the first visit, and after
each new certificate. The log line of each new certificate gives both too. tadoru health --json
gives them under certificates, as fingerprints.certificate_sha256 and
fingerprints.public_key_sha256.
A browser that accepts the certificate makes no client of DoT or DoH trust it. Each client needs
the certificate, or a pin of its key, set by hand. The pin is the key SHA-256 above, in the
pin-sha256 form of RFC 7469.
A start whose store does not read, such as a key that does not match its certificate, stops. To
start again, remove pki/self-signed/ with the server stopped: the next start makes a new
certificate, with a new key and new fingerprints.
A self-signed certificate that does not serve
lists each refusal and each problem.
A certificate from ACME
Section titled “A certificate from ACME”The server can get its certificate from Let’s Encrypt itself, and renew it before it expires. Then
you need no certbot and no certificate files. ACME is the protocol that Let’s Encrypt speaks. Put
these settings in node.toml in place of tls_certificate_file and tls_private_key_file:
tls_listen = ["192.168.1.2:853"]encrypted_allow_recursion = ["0.0.0.0/0", "::/0"]acme_names = ["dns.example.net"]acme_directory = "letsencrypt-staging"acme_terms_agreed = trueacme_http_listen = ["192.168.1.2:80"]acme_terms_agreed = true says that you read the terms of Let’s Encrypt and agree to them. The
server does not agree for you. acme_contact is optional. Let’s Encrypt sends no expiry mail, so
the address is for a problem with your account.
Start with letsencrypt-staging. A staging certificate is not trusted by a phone, but staging has
higher limits, so a mistake in your setup does not use up the real ones. When the health report
reads ok, change acme_directory to letsencrypt. The server then stops serving the staging
certificate and orders a real one at once. Until that order finishes, the encrypted listeners
refuse handshakes again, and the health report reads waiting_for_acme. Each directory keeps its
own account under the state root.
sudo tadoru health --jsonBefore the first certificate, the encrypted listeners refuse the handshakes of clients, and the
health report reads waiting_for_acme. An order takes a few seconds. A restart serves the
certificate the server already holds, and orders a new one only when that one is due. The server
renews at two thirds of the lifetime of the certificate. Where Let’s Encrypt suggests a time
through its renewal information, the server renews at that time instead, which can be earlier or
later, but planned no later than five sixths of the lifetime. A random delay of up to an hour comes
before each scheduled renewal, so servers do not all ask at the same moment. A first order, or an
order after a change of acme_names or acme_directory, starts at once.
The challenge
Section titled “The challenge”Let’s Encrypt checks that the name is yours before it issues. It connects to the name from several networks of the Internet, so the port it checks must answer from the whole Internet. Three challenges are built. Two of them ask a port of this server:
http-01, the default, on port 80. Forward TCP port 80 from your router to an address inacme_http_listen. The server answers one path there, the token of an order, and only while the order runs.tls-alpn-01, on port 443. Setacme_challenge = "tls-alpn-01", and forward TCP port 443 from your router to an address intls_listenorhttps_listen. Choose this one where port 80 is taken or closed.
The third, dns-01, asks the DNS instead. A wildcard name, such as *.example.net, needs it.
“The challenge over DNS” below sets it up.
Port 80 for the challenge and a reverse proxy
Section titled “Port 80 for the challenge and a reverse proxy”Port 80 of a host often has to serve the challenge and plain DoH from a reverse proxy at once. Name
the address in both lists, and the proxy in http_trust:
http_listen = ["192.168.1.2:80"]acme_http_listen = ["192.168.1.2:80"]http_trust = ["192.168.1.10"]The proxy at 192.168.1.10 gets DoH there, as on any address of http_listen. Everybody else, the
authority too, gets the challenge alone, and 403 for any other path. Behind a load balancer in
proxy_protocol_from, the sender is the source that its PROXY header names, so the load balancer
itself makes nobody a proxy. Configuration gives the bounds of a
connection that is not the proxy’s.
The challenge over DNS
Section titled “The challenge over DNS”With dns-01, the authority reads a TXT record at _acme-challenge. and the name. The server
writes that record into a zone that it holds. It waits until the name servers of the zone hold it,
and then it tells the authority to read it. After the order, it removes the record, whatever the
result. No port 80 or 443 takes part. The authority asks port 53 instead.
tls_listen = ["192.168.1.2:853"]encrypted_allow_recursion = ["0.0.0.0/0", "::/0"]acme_names = ["example.net", "*.example.net"]acme_directory = "letsencrypt-staging"acme_terms_agreed = trueacme_challenge = "dns-01"A wildcard is one *. label in front of a host name. *.example.net covers www.example.net, and
not example.net itself or a.b.example.net. List the base name too where the certificate must
cover it, as the example does. The wildcard and its base name share one record name,
_acme-challenge.example.net. The server writes one record for each there, and removes each on its
own.
The zone that holds the record
Section titled “The zone that holds the record”The record goes into a zone of yours under zones/, with kind = "primary" in its zone.toml.
That zone must answer _acme-challenge. and the name, and it must answer the public Internet. The
authority finds the zone through its parent, as any resolver does. So the parent zone must delegate
the zone to name servers that you run, and each of them must hold the record.
In most homes, this server is the one name server of the zone. Then make sure of three things:
- The NS records of the zone name this server by a host name that resolves to your public address.
- The registrar of the domain lists the same name servers.
- The router forwards UDP and TCP port 53 from the outside to this server.
The zone must also be turned on, and its query_from must hold every address. The default holds the
private ranges alone, so write query_from = ["0.0.0.0/0", "::/0"] in the zone.toml of the zone.
The record name must not be at or below a delegation, or below a DNAME. TXT records that stand at
the record name stay, and the record joins them. Each of them must have a lifetime of 60 seconds,
because a set keeps one lifetime and the record of the challenge has 60. The rows of
acme_challenge in Configuration list the refusals.
A CNAME to another zone
Section titled “A CNAME to another zone”A CNAME at _acme-challenge. and the name sends the record to the target of the CNAME. The server
then writes the record at the target, in the zone that holds it. That zone must be a zone of yours
too, and the rules above hold for it. The target must not be a CNAME as well. A CNAME lets you keep
the records of the challenges in a small zone of their own, apart from the zone of the name:
_acme-challenge 300 IN CNAME _acme-challenge.challenges.example.org.The authority reads the CNAME first and then the record. So the wait below asks the name servers of both zones.
Your own address and NAT loopback
Section titled “Your own address and NAT loopback”The server asks each address of each name server of the zone, and that includes its own public address. A router passes a query from inside the network back in to its public address only with NAT loopback, also called hairpinning. Many routers lack it, and then that address gives no answer from inside. The wait fails, though the authority reaches the address from outside.
List such an address in acme_dns01_skip in node.toml, and the wait does not ask it:
acme_dns01_skip = ["203.0.113.7"]The list holds up to 16 IP addresses, without a port. The authority still asks a skipped address, so the router forward must work. A change of the list starts a new order at once.
The wait for the name servers
Section titled “The wait for the name servers”After it writes the records, the server asks every address of every name server in the NS records of the zone. It asks with recursion off. It takes only an answer with the AA bit set, because such an answer comes from the zone itself rather than from a resolver. The answer must hold the exact record. With a CNAME, the name servers of the zone of the CNAME answer first, and then those of the zone of the record. The server asks again every 10 seconds, for at most 5 minutes. When every address passes, the server tells the authority to read the record.
The server finds the addresses of the name servers itself, as it resolves any name. These lookups write no row in the query log. The wait does not read the NS records of the parent zone.
The records after the order
Section titled “The records after the order”The server removes the records of an order after it ends, whatever its result. A removal that a
zone refuses for now, such as a zone that is frozen, keeps its record. The server tries it again
every 10 minutes and at each start. pki/acme/challenges.toml names each record of a
challenge that can still stand in a zone. Only the server writes that file.
When the challenge over DNS fails
Section titled “When the challenge over DNS fails”A failed wait fails the order. The problem of the health report starts with a challenge could not be served: the name servers did not all hold the record within 5 minutes. It names each
server that did not pass, with its address, the zone, the record and the reason. The log shows the
warning the wait for the name servers of a DNS-01 record failed, with the same text.
Where an address gave no answer, the text names NAT loopback and acme_dns01_skip.
A retry after an order whose record the authority was told to read waits at least the negative
lifetime of the zone of the record. That lifetime is the lower of the lifetime of the SOA record
and its MINIMUM field. A resolver of the authority can keep the answer “no such record” that long.
Where that lifetime is longer than the usual wait after a failure, the log says the retry of a DNS-01 order waits the negative lifetime of its zone. The server keeps this wait in memory, so a
restart forgets it, as it forgets the usual wait. An ACME order that
fails gives the usual wait and the problems of the
authority.
The limits
Section titled “The limits”Let’s Encrypt limits how many certificates it issues. The numbers change, so read them on the
page “Rate Limits” of letsencrypt.org. The one you meet first is 5
certificates for the same set of names in 7 days. A renewal does not count where Let’s Encrypt gave
renewal information for the old certificate, because the order then names the certificate it
replaces. The server keeps its certificate across a restart for this reason. A server that loses pki/acme/ orders again at its next start, so five
restores without a backup in a week use up the limit.
Where it lives
Section titled “Where it lives”The account and the certificates live under pki/acme/ in the state root, and only the server
writes there. A backup carries them encrypted, so a backup of a server that uses ACME needs a
passphrase (Backup and restore). A restore then serves the certificate it carried.
More than one server
Section titled “More than one server”Each server orders its own certificate. Two servers behind one name both receive the checks of Let’s Encrypt, and a check that reaches the wrong one fails. Give each server a name of its own.
The router
Section titled “The router”Forward TCP port 853 from the outside to the address in tls_listen. DoT uses TCP alone, so
there is no UDP rule to add.
Do not forward port 53, unless dns-01 needs it, as “The challenge over DNS” above says. Nothing
proves where a UDP query came from. So anybody can send a query in the name of a third party, and
the answer goes there. With allow_recursion open to the outside, the server becomes an open
resolver, and anybody can use it to flood a third party with answers. encrypted_allow_recursion
stays out of that, and only while port 53 stays closed to the outside.
A certificate from ACME needs one more forward: TCP port 80 for http-01, or TCP port 443 for
tls-alpn-01. “A certificate from ACME” above says which.
dns-01 is the one case that needs port 53 from the outside, because the zone of the record must
answer the Internet. Forward UDP and TCP port 53 for it, and keep allow_recursion at its default.
Do not widen allow_recursion while port 53 is open. A stranger then gets the answers of your
zones, and REFUSED for every other name. A REFUSED carries the question back with no records.
Nothing in this build limits the answers of your zones that a stranger gets. The rate limits count
only the clients that allow_recursion holds. So a forged UDP query can still send the answers of
your zones to a third party. Every server that answers a public zone carries this cost.
The phone
Section titled “The phone”Android
Section titled “Android”On Android, open Settings, then Network and internet, then Private DNS. The labels differ between
makers. If you do not find the entry, search Settings for “Private DNS”. Choose “Private DNS
provider hostname”, and type the host name, dns.example.net. Android asks the server on port 853
and checks the certificate. If either fails, Android shows an error under the setting.
iPhone and iPad
Section titled “iPhone and iPad”iOS has no setting in its Settings app for DNS over TLS. It takes a configuration profile instead,
from iOS 14 on. Save
this as tadoru-dot.mobileconfig, with your host name in ServerName:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict> <key>PayloadContent</key> <array> <dict> <key>DNSSettings</key> <dict> <key>DNSProtocol</key> <string>TLS</string> <key>ServerName</key> <string>dns.example.net</string> </dict> <key>PayloadDisplayName</key> <string>Tadoru DNS over TLS</string> <key>PayloadIdentifier</key> <string>net.example.dns.tadoru.dot</string> <key>PayloadType</key> <string>com.apple.dnsSettings.managed</string> <key>PayloadUUID</key> <string>6F1A2B3C-4D5E-4F60-8A71-92B3C4D5E6F7</string> <key>PayloadVersion</key> <integer>1</integer> </dict> </array> <key>PayloadDisplayName</key> <string>Tadoru DNS</string> <key>PayloadIdentifier</key> <string>net.example.dns.tadoru</string> <key>PayloadType</key> <string>Configuration</string> <key>PayloadUUID</key> <string>0A1B2C3D-4E5F-4061-8273-94A5B6C7D8E9</string> <key>PayloadVersion</key> <integer>1</integer></dict></plist>Send the file to the phone with AirDrop, or open it in Safari. Install it under Settings, then General, then “VPN & Device Management”. To stop, remove the profile on the same page.
The profile names no address, so iOS looks the host name up through its usual resolver first. The
name must therefore resolve to your home address from outside. A second profile installed beside
this one needs its own values in both places for PayloadIdentifier and for PayloadUUID. iOS
knows a profile by its PayloadIdentifier, so a second profile with the same one replaces this
one. uuidgen prints a new UUID.
The query log names the phone’s queries with the transport tls. The query log says
how to read it back.
Check it
Section titled “Check it”Ask the server over TLS from a machine outside your network. Inside it, many routers do not send the
public address back in, so name the address of tls_listen after @ there instead.
+tls-ca makes each tool check the certificate against the system’s trusted authorities, and
+tls-hostname names the host name the certificate must hold. dig 9.18 and later speaks
DoT. The dig that macOS ships does not, and kdig from Knot does.
dig +tls-ca +tls-hostname=dns.example.net @dns.example.net example.com Akdig +tls-ca +tls-hostname=dns.example.net @dns.example.net example.com Atadoru health lists the certificate under certificates. Its state is one of seven words. ok
is a certificate in order. expires_soon expires inside 14 days, or inside a sixth of its lifetime
for a certificate from ACME. reload_failed says that the last read of the files was
refused, and expired is a certificate past its date. A certificate from ACME has two more states:
waiting_for_acme before the first certificate, and renewal_failing after an order that failed.
Where no certificate serves yet, a PKCS #12 file reads waiting_for_files until its first read.
This happens where the password changed while a revision that names the file landed, and the
server reads the file again at once. Where that read is refused, the state is reload_failed, with the
refusal in problem. Until the first certificate serves, every handshake fails.
Where two hold, the worse one shows: expired, then reload_failed or renewal_failing, then
expires_soon. The entry also names the file, and the time the certificate expires where one
serves.
sudo tadoru health --jsonFour metrics follow the transport. dns_tls_certificate_expiry_seconds is the Unix time at which
the certificate expires. dns_tls_handshake_failures_total counts the connections that did not finish
the handshake, by reason: timeout, protocol, eof, or no_certificate where no certificate serves yet. dns_tcp_connections_open counts the
open connections by transport, tcp or tls. dns_tls_sessions_evicted_total counts the
sessions that the server dropped early, below.
Resumed sessions
Section titled “Resumed sessions”A phone that connects again resumes its TLS session, which skips most of the handshake. The server keeps each session in memory, and a session ends 12 hours after the full handshake that began it, however often the phone resumed in between. The 12 hours count by the clock on the wall and by the time the machine has run, whichever says 12 hours first, so a night that the machine sleeps counts too. Then the phone makes one full handshake, and resumes from it for the next 12 hours.
- A phone that speaks TLS 1.2 alone, such as Android 9, resumes by session ID.
- A TLS 1.3 phone gets one new ticket at each connection. The new ticket ends when the session of the full handshake ends, not 12 hours after the connection that gave it. The ticket says 24 hours, and the server refuses it after 12.
- A client that resumes TLS 1.2 by ticket alone, with no session ID, makes a full handshake every time.
DNS over TLS and DNS over HTTPS keep 4096 sessions each. A session is new until its client resumes from it once, and resumed after that. A client that keeps resuming holds one resumed session, and every full handshake stores one new session. A full store drops the new session that ends first, unless more than 3072 sessions are resumed: then it drops the resumed one that ends first. So a flood of new connections pushes out new sessions alone, and the clients that come back keep theirs.
One address holds 32 sessions at most. A new session of an address that holds 32 pushes out the
new session of that address that ends first. Where all 32 are resumed, as behind a NAT of many
phones, it pushes out the resumed one that ends first. So the clients behind one address compete
among themselves, and no other address loses a session. A household behind one address holds one
session for each phone that resumes. A phone that resumes a TLS 1.2 session from a new address
moves the session to that address. A network, a /24 of IPv4 or a /56 of IPv6, holds 256
sessions at most by the same rule. Behind a load balancer, the address is the client
that the PROXY header names, so send the header: without it, every client counts as the address
of the load balancer and shares its 32 sessions. A restart and a new certificate drop them all, so each client makes one full
handshake then.
dns_tls_sessions_stored shows how many sessions each store holds, by part, new or
resumed.
dns_tls_sessions_evicted_total counts each session that the store dropped before its 12 hours,
by transport, tls or https, and by reason. A restart and a new certificate count nothing.
The count stays at 0 on a home network whose few clients resume as they normally do.
capacity_new: a full store dropped a new session. A steady rise is a peer that connects and never resumes, such as a monitoring probe every 10 seconds, or a flood of new connections.capacity_resumed: a full store with more than 3072 resumed sessions dropped one. There are more clients that come back than one store holds.address: an address that held 32 sessions dropped its own new one. A steady rise is one peer that never resumes, or many clients behind one address.address_resumed: an address that held 32 resumed sessions dropped its own resumed one for a newcomer. More phones that come back sit behind that address than it holds.prefixandprefix_resumed: the same for a network that held 256 sessions.
A session that went costs its client one full handshake when it comes back, and nothing breaks.
DNS over HTTPS
Section titled “DNS over HTTPS”DoH carries the same queries as DoT, inside HTTP requests. A client asks one URL: the host name of
the certificate, then the path in http_path, /dns-query by default. Every setting has its row
in “DNS over HTTPS” in Configuration. A query over DoH reads
encrypted_allow_recursion, the same list as DoT.
Choose one of two ways. Port 443 serves one program, so a machine that runs a reverse proxy on 443 already uses the second way.
- The server holds the TLS session itself, on
https_listen. Use this when nothing else on the machine answers on port 443. - A reverse proxy, such as Caddy or nginx, holds the TLS session. It sends each request on in
plain HTTP, to
http_listenor to the socketdoh.sock. Use this when the proxy already holds port 443 and a certificate for your sites.
The server on port 443
Section titled “The server on port 443”Add one setting to the four of DoT. The server serves the certificate of DoT on this address too, and reloads both from the same two files.
https_listen = ["192.168.1.2:443"]Forward TCP port 443 from your router to that address. DoH over HTTP/2 and HTTP/1.1 uses TCP alone, so there is no UDP rule to add.
Behind a reverse proxy
Section titled “Behind a reverse proxy”The plain listeners answer a trusted proxy and nobody else. A peer of http_listen outside
http_trust gets 403, and the server reads nothing it sends. A peer of doh.sock is trusted,
because the file mode of the socket decides who can open it.
The proxy names the client in the header X-Forwarded-For. The server reads the last address in
that header, because the proxy appends the address it saw there. The client in that header is the
client for encrypted_allow_recursion, for the rate limits and for the query log. A request from
a trusted proxy without that header gets 400, so a proxy set up wrong shows at once. On https_listen
and http_listen, a proxy you remove from http_trust loses each open connection at its next
request. Its new connections then count against the connection limit of one client. If your proxy
sends another header, such as X-Real-IP, name it in http_client_header.
An entry of http_trust that starts with ! takes a machine out of a wider entry, and the entry
with the longest prefix that holds the machine decides. With http_trust = ["10.0.0.0/29", "!10.0.0.5"], every machine of 10.0.0.0/29 is a trusted proxy but 10.0.0.5, which is a
client. http_listen gives it 403, https_listen and http3_listen read no header from it, and
its connections count against the limit of one client. A deny entry that you add while a request
of that proxy waits refuses the request, as a removal does. A machine of the denied range that asks
for the encrypted listeners gets the DoH listener, as any client outside the list does.
A list whose allow entries hold every public address of a family, such as 0.0.0.0/0 or
2000::/4, is refused, because any machine could then name a client of your network.
Configuration gives the rules of a deny entry, and the list to
write for an older build.
Caddy sets X-Forwarded-For by default. On the machine of the server, a TCP listener on the
loopback address needs these settings in node.toml:
http_listen = ["127.0.0.1:8053"]http_trust = ["127.0.0.1"]Then send the path to it in the Caddyfile:
dns.example.net { reverse_proxy /dns-query 127.0.0.1:8053}If Caddy runs on another machine, use an address of the server’s machine in http_listen. Put
the address of the Caddy machine in http_trust.
nginx sends X-Forwarded-For only when its configuration says so. Use the same two settings as
for Caddy, and this location in the server block that holds your certificate:
location /dns-query { proxy_pass http://127.0.0.1:8053; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}The socket doh.sock
Section titled “The socket doh.sock”A Unix socket needs no port and no http_trust. The proxy must run on the machine of the
server. Turn the socket on in node.toml:
http_socket = trueThe server makes doh.sock in its runtime directory, /run/tadoru/doh.sock with the package.
Its mode is 0660, and its group is the group of the server, tadoru. Add the proxy’s user to
that group, then restart the proxy so that it gets the group. The user is caddy for Caddy. For
nginx, it is www-data on Debian and Ubuntu and nginx on most other systems.
sudo usermod -aG tadoru caddysudo systemctl restart caddyPoint the proxy at the socket. In the Caddyfile:
dns.example.net { reverse_proxy /dns-query unix//run/tadoru/doh.sock}In nginx, change the proxy_pass line of the location above:
proxy_pass http://unix:/run/tadoru/doh.sock:;In a container, use http_listen rather than the socket. The proxy then reaches the server
through the network, and no group crosses between the two.
The browser and the phone
Section titled “The browser and the phone”In Firefox, open Settings, then Privacy and Security, then the part for DNS over HTTPS. Choose
Max Protection, choose a custom provider, and type the URL:
https://dns.example.net/dns-query. In Chrome and Edge, the entry is “Use secure DNS”, under
Privacy and security. Choose a custom provider there and type the same URL.
An iPhone or an iPad takes the profile of “iPhone and iPad” above, with two changes in the inner
DNSSettings. DNSProtocol is HTTPS, and a ServerURL takes the place of ServerName:
<key>DNSSettings</key> <dict> <key>DNSProtocol</key> <string>HTTPS</string> <key>ServerURL</key> <string>https://dns.example.net/dns-query</string> </dict>Give this profile its own values for PayloadIdentifier and PayloadUUID, so that it does not
replace the profile of DoT. iOS uses one DNS profile at a time, which you choose under Settings,
then General, then “VPN & Device Management”, then DNS.
The query log names these queries with the transport https, through the server and through a
proxy alike.
Check DoH
Section titled “Check DoH”curl sends a query as a GET. The value of dns is a query for example.com, type A, in
base64url. The answer is a DNS message in the wire format, so xxd shows it. kdig speaks DoH as
well.
curl -sS -H 'Accept: application/dns-message' \ 'https://dns.example.net/dns-query?dns=AAABAAABAAAAAAAAB2V4YW1wbGUDY29tAAABAAE' | xxdkdig +https @dns.example.net example.com AA status other than 200 carries no DNS answer. Add -i to curl to see the status.
An HTTP error from DNS over HTTPS says what
each status means. The counter dns_https_responses_total counts the answers by status.
The page in a browser
Section titled “The page in a browser”Open the URL of DoH in a browser, such as https://dns.example.net/dns-query. The server answers
with a short page. It says that the address is a DNS over HTTPS endpoint, and it gives the URL to
set in a browser or a device:
- The URL comes from
tls_server_nameandhttp_path. It has the port of the listener where that port is not 443. - The page also names DNS over TLS and DNS over QUIC, with the host name and their ports, where this node serves them.
- With no
tls_server_name, the page gives the path alone. Use it with the host in the address bar. - Behind a reverse proxy or a load balancer, the server does not know the public port. The page then gives the URL with no port, and says that it assumes port 443.
The page holds nothing of the request. A browser gets it for a GET with no variable dns, whose
Accept asks for text/html at a weight above zero and at least that of application/dns-message.
curl, with its Accept: */*, still gets 400, and a DoH client still gets its answer. A page counts as
a 200 in dns_https_responses_total.
The page shows the host name and the ports of node.toml to anybody who reaches the listener. To
turn it off, set http_help_page = false. A browser then gets the 400 or 406 of a DoH request with
no query.
DNS over QUIC and HTTP/3
Section titled “DNS over QUIC and HTTP/3”DoQ carries each query on its own QUIC stream, on UDP port 853. DoH3 carries the requests of DoH
on HTTP/3, on UDP port 443. A lost packet holds up only its own query. A connection stays on the
address it started from: the server drops each packet of it from another address. So a phone that
moves from Wi-Fi to mobile data opens a new connection, which costs one handshake. Following the
client to its new address would let a packet from a forged address take over the answers. Both read the certificate of DoT, from the same two files, and
encrypted_allow_recursion decides who gets answers. Every setting has its row in “DNS over QUIC”
in Configuration.
A DoQ or DoH3 client that connects again resumes its session from a ticket, which skips the certificate. The server seals each ticket with a key that seals for 6 hours and opens tickets for 12 hours after the server made it, by the clock on the wall and by the time the machine has run. So a ticket resumes for 6 to 12 hours, and after that the client makes one full handshake. A restart and a new certificate make new keys, so each client makes one full handshake then too.
The settings
Section titled “The settings”Add one or both lists to the four of DoT. The same address and port can be in tls_listen and
quic_listen, because one is TCP and the other UDP. Port 853 on both is the usual setup, and so is
443 for https_listen and http3_listen.
quic_listen = ["192.168.1.2:853"]http3_listen = ["192.168.1.2:443"]Save the file. The server applies the change at once. A revision that removes an address closes
its open connections at once, so a client moves on rather than waits for its timeout. A DoH3
client reads the code of no error, H3_NO_ERROR, unless the server closed with another code
first. A connection that was still in its QUIC handshake, or had just finished it, has no
guaranteed code of HTTP/3.
A response of https_listen names the http3_listen port of the same address in an Alt-Svc header.
A browser that reaches the server over HTTPS then tries HTTP/3 by itself.
What a DoH3 client gets wrong
Section titled “What a DoH3 client gets wrong”The DoH3 listener holds each client to these rules. Each one ends the stream or the connection with a code of HTTP/3 that a client logs. “A DoH3 request that the server resets” in Troubleshooting gives each code.
- The setup of HTTP/3 takes at most 10 seconds after the handshake. A client that gives the server no room for its own streams in that time is closed.
- The head of each request comes within 10 seconds of the start of its stream. A late head is reset, and the server never reads the query.
- A HEADERS frame takes at most 17 KiB, and any other frame but DATA at most 16 KiB. A longer one ends its stream, and on the control stream the connection. A head whose fields pass 16 KiB once decoded gets 431.
- A frame that ends before its length, or that holds more than its type allows, closes the connection.
- A client that stops reading an answer drops its query, so the server stops waiting for the upstream of a query nobody waits for.
- A connection on which more requests drop before their head than twice
quic_max_streamsis closed.
The router
Section titled “The router”Forward UDP port 853 to the address in quic_listen, and UDP port 443 to the address in
http3_listen. These are UDP rules, beside the TCP rules of DoT and DoH on the same ports.
The three numbers
Section titled “The three numbers”Three settings apply to every QUIC listener. The defaults suit a home network.
quic_idle_timeout_seconds, 30 by default, is how long a quiet connection stays open. If a phone reconnects too often, raise it. The shorter of the server’s and the client’s values applies.quic_max_streams, 100 by default, is how many queries one connection can have open at once. A client past it waits for a query to finish.quic_backlog, 256 by default, is how many connection attempts can be pending, not yet accepted or refused. Past it, a new attempt is dropped, and the client sends it again a moment later.
The client
Section titled “The client”AdGuard apps speak DoQ: give them quic://dns.example.net. A browser finds DoH3 by the Alt-Svc
header, with the DoH URL it already has. The query log names DoQ queries with the transport
quic, and DoH3 queries with https, the same as DoH on HTTP/2.
Check DoQ and DoH3
Section titled “Check DoQ and DoH3”kdig 3.3 and later speaks DoQ, and the dig of BIND does not. curl speaks HTTP/3 where it was built with it.
kdig +quic @dns.example.net example.com Acurl -sS --http3-only -H 'Accept: application/dns-message' \ 'https://dns.example.net/dns-query?dns=AAABAAABAAAAAAAAB2V4YW1wbGUDY29tAAABAAE' | xxddns_quic_connections_open counts the open connections by protocol, doq or h3. A query over
DNS over HTTPS on HTTP/3 has the transport h3 in the query log and on dns_queries_total, apart
from https. Older versions named it https, and their rows keep that word.
dns_quic_retries_total counts the attempts the server asked to prove their address. It asks a
client that has not proven its address yet, when 64 attempts weigh on the listeners or the client
is at its connection cap. Those attempts are the handshakes in progress, and the attempts from
addresses not yet proven that hold no place of their client, until they are gone.
dns_quic_connections_refused_total counts refusals by reason: budget where the listeners hold
1000 connections, client where one client is at its cap, and untracked where the server cannot
see when a connection is gone, which Troubleshooting
explains. dns_quic_connections_held shows the places that are taken now.
dns_quic_handshake_failures_total and dns_quic_protocol_errors_total count the attempts and the
clients that broke the rules.
Every DoQ and DoH3 address shares one budget of 1000 connections, also across a revision: a
listener that a revision removes keeps the places of its connections until they are gone, and a
new listener takes only the free ones. So load on DoH3, or on one address, can refuse DoQ or
another address with budget. Before this version, each address had 1000 of its own. A connection
counts against the 1000 from the start of its handshake, and against the cap of its client once
its address is proven, until it is gone. A closed connection is gone three probe timeouts after
its close: a few round trips, about 3 seconds where the client sends no reply, and longer for a
slow client. So a client that connects and closes in a loop meets its cap and the budget as if
each connection stayed open that long.
Encrypted forwarders
Section titled “Encrypted forwarders”The server sends each question it cannot answer to the upstreams in forwarders. Over plain DNS,
anybody on the path to them reads each name. An encrypted entry asks over TLS, HTTPS on HTTP/2 or
HTTP/3, or QUIC instead:
forwarders = [ "tls://dns.quad9.net (9.9.9.9, 149.112.112.112)", "tls://one.one.one.one (1.1.1.1, 1.0.0.1)",]The part before the parentheses is the name on the upstream’s certificate. The parentheses hold the addresses the server connects to, because it never looks the name up. “Encrypted forwarders” in Configuration gives every form and every refusal.
The four large services
Section titled “The four large services”Each cell is an entry as the service publishes it.
| Service | DNS over TLS | DNS over HTTPS | DNS over QUIC |
|---|---|---|---|
| Cloudflare | tls://one.one.one.one (1.1.1.1, 1.0.0.1) |
https://cloudflare-dns.com/dns-query (1.1.1.1, 1.0.0.1) |
none |
tls://dns.google (8.8.8.8, 8.8.4.4) |
https://dns.google/dns-query (8.8.8.8, 8.8.4.4) |
none | |
| Quad9 | tls://dns.quad9.net (9.9.9.9, 149.112.112.112) |
https://dns.quad9.net/dns-query (9.9.9.9, 149.112.112.112) |
none |
| AdGuard | tls://dns.adguard-dns.com (94.140.14.14, 94.140.15.15) |
https://dns.adguard-dns.com/dns-query (94.140.14.14, 94.140.15.15) |
quic://dns.adguard-dns.com (94.140.14.14, 94.140.15.15) |
A list holds encrypted entries alone, or plain entries alone. Name two services, so a bad day at either still answers. The server prefers the fastest address and keeps a small share going to the others.
DNS over HTTPS on HTTP/3
Section titled “DNS over HTTPS on HTTP/3”An h3:// entry asks DNS over HTTPS on HTTP/3, over UDP, as in
h3://dns.example.net/dns-query (192.0.2.1). It takes the form of an https:// entry and the same
answer: a 2xx status, the type application/dns-message, and a body of at most 65535 octets. The
server never falls back from it to HTTP/2 or to plain DNS. A resolver that answers both is two
entries. Where a network blocks UDP to port 443, the h3:// entry fails and an https:// entry
still answers over TCP.
DNS over QUIC and HTTP/3 share one UDP socket of the server for each address family. A query that
the server no longer waits for, such as the slower of two in a race, resets its request, so the
resolver stops its work. When a resolver closes a connection with a GOAWAY, the next query opens a
new one. The query log names the step h3.
The DNS client asks an h3:// server over HTTP/3 too, with the transport h3, and never falls
back to HTTP/2 either.
Through a SOCKS5 proxy, by its name
Section titled “Through a SOCKS5 proxy, by its name”Where the forwarders go through a SOCKS5 proxy, such as the SOCKS5 port of Tor, an encrypted entry can leave out its addresses. The proxy looks the name up, and this machine looks up nothing:
outbound_proxy = "socks5://127.0.0.1:9050"outbound_proxy_for = ["blocklists", "acme", "updates", "forwarders"]
# server.tomlforwarders = ["tls://dns.quad9.net"]A name under onion takes this form alone, and only through a SOCKS5 proxy. DNS over QUIC and
HTTP/3 are refused through any proxy, which carries TCP alone. On any other route an entry with no
addresses is refused, and so is a change of node.toml that takes the route away
(Requests through a proxy). The query log and the
metrics then name the upstream by its name and port.
No plain fallback
Section titled “No plain fallback”An encrypted query never goes out in plain text. If every encrypted upstream fails, the query answers SERVFAIL. A list that mixed plain and encrypted entries would answer from the plain one whenever the encrypted ones fail, and anybody who can block port 853 could then read every name. So the server refuses such a list.
A [[forward]] sends a suffix, such as home.lan, to the resolvers in its to. Most often that
is the router, which speaks plain DNS on port 53. A to also takes every encrypted form of
forwarders, such as tls://dns.corp.example (10.0.0.53). One forward holds plain destinations or
encrypted ones, not both, and an encrypted one never falls back to plain text. The DS question for
the suffix itself goes by forwarders or by recursion, as
Configuration says.
A resolver with a private certificate
Section titled “A resolver with a private certificate”The server checks each certificate against the trust store of the machine, the store that the system’s own tools use. A browser can keep a store of its own, so a root added there alone does not count. A resolver on your network with a certificate from your own certificate authority works once that authority is in the store:
- Copy the root certificate of your authority, in PEM, to
/usr/local/share/ca-certificates/, with a name that ends in.crt. - Run
sudo update-ca-certificates. - Restart the server. It reads the store once, at start.
The server reads only regular files of the store, each up to 16 MiB, and a link to one. The two
variables of OpenSSL point the read somewhere else. SSL_CERT_FILE counts whenever it is set, even
to nothing. SSL_CERT_DIR counts only where it names at least one directory: split at :, with
the empty parts dropped, so SSL_CERT_DIR="" or ":" leaves the store of the system. Where either
counts, the server reads those paths alone, and a missing file then gives no root. A file that the
server refuses is a warning at start, as Troubleshooting says.
That is the Debian and Ubuntu path. Other systems have their own tool, such as
update-ca-trust on Fedora. The container image carries the CA bundle of Debian, so a public
upstream works there with no step. For a private root in a container, mount a CA bundle that holds
it over /etc/ssl/certs/ca-certificates.crt.
Check it
Section titled “Check it”Send a query, then read the metrics of the server:
$ dig @127.0.0.1 example.com A$ curl -s http://127.0.0.1:9153/metrics | grep 'dns_upstream_queries_total'The protocol label reads tls, https, quic or h3 for the encrypted upstreams.
dns_upstream_connections_open shows the connections that are open now, and
dns_upstream_handshakes_total counts each handshake. A DoT or DoH handshake that resumed an
earlier session counts with resumed="true", and a handshake of DoQ or of h3 counts with
resumed="unknown".
Padding
Section titled “Padding”Encryption hides the bytes of a message, but not their number. A long name makes a long query, and a large answer makes a long reply, so the length alone tells an observer much about the name. The server pads its messages to a few fixed sizes, so many names share one size. There is no setting for it.
- An answer over DoT, DoH or DoQ grows to a multiple of 468 octets, when the query carries an OPT record, which most clients send. DoT has one exception, in the next item. The refusal a client gets when it passes its rate limit grows the same way.
- Over DoT, the answer grows only up to the size the client said it can take, such as 1232 octets. A larger answer goes out whole and unpadded.
- Over DoQ, the packets that the server sends after the handshake grow to the largest size the path takes, at least about 1200 octets. So an answer to a query without an OPT record is padded too. An acknowledgement alone grows as well. A packet that only probes for a lost packet stays short.
- A query that the server sends to an encrypted forwarder grows to a multiple of 128 octets.
- Plain DNS on port 53, over UDP or TCP, is never padded. Padding there hides nothing, because anybody on the path reads the whole message.
dns_padded_responses_total counts the answers that carry the padding option, by transport.
Compare it with dns_responses_total for tls and https. A large gap means, most often, that
some clients send no OPT record, and their answers go out unpadded. Over DoT, an answer larger
than the size the client can take adds to the gap too. For quic the gap means less, because the
packets of those answers are padded anyway.
To see the padding, ask over DoT with dig 9.18 or later:
$ dig +tls +padding=128 @192.168.1.2 example.com AThe OPT pseudosection of the answer shows the padding option and its length.
Behind a load balancer
Section titled “Behind a load balancer”A load balancer that relays TCP, such as HAProxy, hides the address of the client: the server sees
the load balancer as the peer. The PROXY protocol gives the address back. The load balancer puts a
short header in front of what it relays, and the header names the client. The server reads it from
the sources in proxy_protocol_from in node.toml, and from nobody else.
listen = ["192.168.1.2:53"]tls_listen = ["192.168.1.2:853"]proxy_protocol_from = ["192.168.1.3"]A source in the list must send the header on every DNS listener: listen on UDP and TCP,
tls_listen, https_listen and http_listen. A connection from it without a header is closed with no answer,
and a datagram from it without one is dropped. A source outside the list never has a header read.
A header from such a source closes the connection, or drops the datagram. The QUIC listeners,
quic_listen and http3_listen, never read a header, because a header in front of a QUIC packet
breaks QUIC.
List the load balancers alone. A list whose entries hold every public address of a family, such
as 0.0.0.0/0 or 2000::/4, is refused, because any machine on the internet could then name its
own client address. Troubleshooting
gives the message.
Where the header names the client itself, that client is the client for
encrypted_allow_recursion, for the rate limits, for the connection limit and for the query log.
“A proxy behind the load balancer” below covers a header that names a proxy. The log holds the client in client and the load
balancer in via. Clients says how the server names the client behind a load
balancer.
HAProxy
Section titled “HAProxy”HAProxy relays TLS without opening it, so the server keeps its own certificate. Put
send-proxy-v2 on each server line. This haproxy.cfg relays plain DNS over TCP and DoT:
frontend dns_tcp bind :53 mode tcp default_backend tadoru_tcp
backend tadoru_tcp mode tcp server tadoru 192.168.1.2:53 send-proxy-v2
frontend dot bind :853 mode tcp default_backend tadoru_dot
backend tadoru_dot mode tcp server tadoru 192.168.1.2:853 send-proxy-v2send-proxy sends the older text form of the header, and the server reads it too. DoH on port 443
works the same way, with a third pair that relays to an address of https_listen. The open source
HAProxy relays no UDP, so plain DNS over UDP does not go through it.
A load balancer that relays UDP with a header can be listed too. Anybody who can forge the source address of that load balancer can then choose the client address of a datagram. List a UDP load balancer only where nobody outside can forge its address, and prefer TCP otherwise. A dynamic update that comes this way is refused, whatever client the header names.
A proxy behind the load balancer
Section titled “A proxy behind the load balancer”A reverse proxy for DoH can sit behind the load balancer. The load balancer names the proxy in its
header, and the proxy names the client in X-Forwarded-For. Put the load balancer in
proxy_protocol_from and the proxy in http_trust. The server reads the HTTP header only from a
proxy in http_trust, and it reads that list against the source that the PROXY header named, not
against the load balancer.
The client in X-Forwarded-For is then the client for encrypted_allow_recursion, for the rate
limits and for the query log. The proxy carries many clients, so the limit on connections per
client does not count its connections. A source that the PROXY header names and that is not in
http_trust is a client: the server counts its connections and reads no HTTP header from it.
A client that finds the encrypted listeners by itself
Section titled “A client that finds the encrypted listeners by itself”A client that you gave the plain address of this server can learn its encrypted listeners and move
to them. The client asks plain DNS for _dns.resolver.arpa, type SVCB, and the server answers with
the DoT, DoH and DoQ listeners on the address the client asked. This is called discovery of
designated resolvers. Whether a client asks, and which setting turns it on, depends on the client.
The server answers with the listeners when all of these hold:
tls_server_nameinnode.tomlnames the host that clients reach the encrypted listeners by, such asdns.home.example.advertise_encryptedstaystrue, which is the default. The certificate can hold that name, the plain address, or both, as “What the client checks” below says.- A zone of this server gives that name exactly one address, with an A or an AAAA record. The address is a plain listener address that has an encrypted listener on it too. The answer names the listeners of that one address, and every other plain address answers with no record.
- A certificate serves the encrypted listeners.
- The client is inside
allow_recursionfor the plain question it asks, and insideencrypted_allow_recursionfor the listener it moves to. Its group blocks neither the A nor the AAAA lookup of the name oftls_server_name.
A client that is itself in http_trust gets no DoH listener, because the DoH listener wants a
client header from it. A client in proxy_protocol_from gets no listener at all, because every
listener wants a PROXY header from it.
For example, a server on 192.168.1.2 with DoT on port 853:
listen = ["192.168.1.2:53"]tls_listen = ["192.168.1.2:853"]tls_certificate_file = "/etc/letsencrypt/live/dns.home.example/fullchain.pem"tls_private_key_file = "/etc/letsencrypt/live/dns.home.example/privkey.pem"tls_server_name = "dns.home.example"The zone of home.example holds this line beside its other records. Local Zones shows a
whole zone.
dns IN A 192.168.1.2Then dig @192.168.1.2 _dns.resolver.arpa SVCB answers with one record, and the address record of
dns.home.example in the additional section:
_dns.resolver.arpa. 300 IN SVCB 1 dns.home.example. alpn="dot" ipv4hint=192.168.1.2dns.home.example. 300 IN A 192.168.1.2What the client checks
Section titled “What the client checks”A client that found the server by its address checks the address in the certificate, not the name.
GET /api/health says what a client can do on each plain address, in discovery.certificate:
| Word | What it means |
|---|---|
verified |
The certificate holds the address, so a client that checks it moves |
opportunistic |
The certificate does not hold the address, and a DoT or DoQ listener is named there |
none |
The answer names no listener there, or names DoH alone and the certificate lacks the address |
A public authority such as Let’s Encrypt issues no certificate for a private address. So a server at
home with a public certificate reads opportunistic, which is the expected case. A client that
accepts that mode then uses the listener without checking the address. A certificate from your own
authority, which your devices trust, can hold the private address and read verified.
This page names no client that moves by itself yet, because none was tested with this server.
Groups and access
Section titled “Groups and access”A client that follows the answer connects to the address it asked. So a group that an arrived_on
entry selects stays the same over the encrypted listener. An arrived_on group is no access control,
though: any client that reaches one address of this server can name another address itself. The
recursion lists decide who the server resolves for: allow_recursion for plain DNS, and
encrypted_allow_recursion for DoT, DoH and DoQ. Each reads the address of the client, whichever
address of this server it asked.
discovery in GET /api/health names the problems in plain sentences: a name the zones do not give
one address, a zone of the name that the start stopped, a set of listeners that the answer leaves
out, and a DoH path that gives no record.
What a stranger gets
Section titled “What a stranger gets”With encrypted_allow_recursion open to everybody, anybody who finds the address and the name can
use the server as you do. That gives them three things:
- The resolver. They can ask any name, and the cache answers them as it answers you.
- Your blocking. A name you block is blocked for them too, and what the server answers for it tells them which lists you use.
- Your local zones, where
query_fromholds them. By defaultquery_fromholds the private ranges alone, so a stranger, and your phone away from home too, gets REFUSED for the names of your zones. To let the phone read them, write its networks, or every address, inquery_fromof[zones]inserver.toml, and every client on that list can then ask for the names of the machines on your network. The start warns whileencrypted_allow_recursionholds a network that the default ofquery_fromleaves out.
The rate limits apply to every client, so one stranger cannot make the server do much work. Nobody can forge an address over TLS or HTTPS, because the TCP handshake proves the address first. So nobody can make the server send its answers to a third party.
If the zones hold names you want to keep, keep the list closed. List the networks your phone uses instead, such as the range of your mobile carrier. The phone then loses the server on any other network.
When it does not answer
Section titled “When it does not answer”- The phone says it cannot connect. Check the router forward first, from outside your network:
kdig +tls @dns.example.net example.com. Then check thattls_listennames the address the router forwards to. - The phone says the certificate is not valid. The host name on the phone must be a name the
certificate holds.
tadoru healthshows whether the certificate expired. - A query gets REFUSED. The client’s address is outside
encrypted_allow_recursion. Behind a proxy, that address is the one in the client header, not the address of the proxy. - A DoH client gets an HTTP error and no answer. An HTTP error from DNS over HTTPS says what each status means.
- The change was refused. The refusal names the setting or the file. A certificate file the server will not take covers every refusal of the two files.
- An encrypted forwarder fails, and the log warns that its certificate was refused. A certificate of a forwarder that is refused gives the causes.
- A DoQ or DoH3 client cannot connect, while DoT and DoH work. The router has no UDP rule for the
port, or the address is missing from
quic_listenorhttp3_listen. A QUIC listener the server will not take covers the refusals of the two lists. - Nothing answers through a load balancer, or a machine in
proxy_protocol_fromgets no answer of its own. A listed address that gets no answer gives the causes.