Repository navigation
Description
DNS-over-TLS in dnsproxy does not set the ALPN protocol to "dot" in the TLS configuration. While this is not strictly required by RFC 7858, there are practical scenarios where it becomes necessary.
Problem
In upstream/dot.go, the tls.Config is constructed at line 61 without setting the NextProtos field to []string{"dot"}:
tlsConf: &tls.Config{
ServerName: addr.Hostname(),
RootCAs: opts.RootCAs,
CipherSuites: opts.CipherSuites,
ClientSessionCache: tls.NewLRUClientSessionCache(0),
MinVersion: tls.VersionTLS12,
InsecureSkipVerify: opts.InsecureSkipVerify,
VerifyPeerCertificate: opts.VerifyServerCertificate,
VerifyConnection: opts.VerifyConnection,
},Why it matters
-
RFC 8932 (Recommendations for DNS Privacy Service Operators) — references the
"dot"ALPN value for DoT when deployed alongside DoH on the same IP address/port. Servers that serve both DoT and DoH on port 443 (like NextDNS) rely on ALPN to distinguish the two protocols. -
RFC 9461 (Service Binding Mapping for DNS Servers) — uses
alpn=dotin SVCB/HTTPS DNS records to advertise DoT support. When connecting to such servers, the client should signal the"dot"ALPN to match what was advertised.
Practical impact
Some DNS-over-TLS providers (e.g., NextDNS on non-standard port 443) rely on ALPN to differentiate DoT from DoH traffic. Without the ALPN set to "dot", connections to such providers may fail or be misinterpreted.
You can reproduce it by configuring upstream to tls://dns.nextdns.io:443, it will only work with dot in ALPN it works.
Fix
Add NextProtos: []string{"dot"} to the tls.Config in newDoT():
tlsConf: &tls.Config{
ServerName: addr.Hostname(),
RootCAs: opts.RootCAs,
CipherSuites: opts.CipherSuites,
ClientSessionCache: tls.NewLRUClientSessionCache(0),
MinVersion: tls.VersionTLS12,
InsecureSkipVerify: opts.InsecureSkipVerify,
VerifyPeerCertificate: opts.VerifyServerCertificate,
VerifyConnection: opts.VerifyConnection,
NextProtos: []string{"dot"},
},
Activity