[Proposal] DoH and NextDNS upstream nameserver support #6365
GustavoKatel
started this conversation in
Ideas & Feature Requests
Replies: 2 comments
0 replies
|
Needs DoT as well |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
Add DNS-over-HTTPS (DoH) and NextDNS as upstream
ns_typevalues alongside the existing UDP nameservers. Admins attach DoH endpoints or NextDNS profiles to a Nameserver Group through the same REST API; the client speaks RFC 8484 to them. For NextDNS, queries carry the local peer's FQDN as the device identifier so devices appear by name in the NextDNS dashboard.Related: #2232 (DoH/DoT support — this proposal covers the DoH half), #3711 (NextDNS profile compatibility).
I have a working implementation and would like to validate the design before opening the PR. AI assistance was used during development.
Branch:
GustavoKatel/netbird:doh-upstream-target-refactor— 8 layered commits, each reviewable independently. Diff vsnetbirdio:main.Proto change
NameServermessage gets one optional field:Older clients ignore an unknown
NSType(they already logskipping nameserver … this peer supports only udpand treat the group as empty). Purely additive.REST change
Nameserverschema:ns_typeenum gains"doh"and"nextdns"urlfieldipandportbecome optional (still required forudp)Per-type validation:
udp— requiresip+portdoh— requiresurl(fullhttps://…endpoint)nextdns— requiresurl(just the profile / config ID)Client implementation
upstreamRaceis reshaped from[]netip.AddrPortto a slice of typed targets carrying NSType + AddrPort + URL, so one race can hold mixed UDP/DoH entries without colliding on the zero AddrPort. The per-target health map is rekeyed accordingly.dohClientperforms the HTTPS exchange. The per-platform UDP impls (upstream_general,upstream_ios,upstream_android) are unchanged.https://dns.nextdns.io/<config_id>and per-request HTTP headers carryX-Device-Name=<FQDN>andX-Device-Id=<short hostname>, matching the convention used bynextdns/nextdns.nbnet.NewDialer()— the same per-platform "bypass the netbird tunnel" dialer netbird already uses for grpc/signal/STUN — so the HTTPS connection todns.nextdns.iodoesn't loop back into the resolver.Bootstrap resolution
DoH endpoint hostnames can't be resolved through the OS resolver once netbird has taken it over — the lookup would loop. The client bootstraps from
hostManager.getOriginalNameservers()(the same pre-takeover snapshot that already backsPriorityFallback), with our own DNS service IP filtered out. No hardcoded fallback resolver; if the bootstrap list is empty the client fails the DoH exchange and the race moves on to the next upstream.Platform support
DoH coverage matches what
nbnet.NewDialeralready provides per platform — no new platform abstraction introduced:IP_BOUND_IFto underlying interfaceIP_UNICAST_IFVpnService.protect()http.Transportwould need to route throughnetstack; out of scope for v1Backward compatibility
doh/nextdnsnameserver in their network map log a single warning and skip that entry, treating the group as if it were empty — same code path as today's "non-UDP" check. Peer keeps working with whatever other nameservers it had.Verified
Open design questions
dohandnextdnsas separate types, or genericdohonly with NextDNS-vs-other detected from the URL on the client?URLoverloaded as "full URL or config ID depending onNSType", or a separate field per type (e.g.URL+ConfigID)?X-Device-Name= FQDN,X-Device-Id= short hostname (deterministic, no per-peer config), or do you want admins to template the device-name string?hostManager.getOriginalNameservers()is enough for normal operation. Should we also expose an admin-levelbootstrap_serversfield on the management config as an explicit override, or leave that as a follow-up if anyone hits a corner case?I'll wait for design feedback before opening the PR.
All reactions