Skip to content

Always query DNS records over TCP instead of UDP#540

Merged
jsha merged 1 commit intoletsencrypt:mainfrom
kanashimia:tcp-retry
Feb 17, 2026
Merged

Always query DNS records over TCP instead of UDP#540
jsha merged 1 commit intoletsencrypt:mainfrom
kanashimia:tcp-retry

Conversation

@kanashimia
Copy link
Contributor

TXT records can be quite large, with is a problem for DNS challenges, they don't fit in the 512 buffer especially if there are multiple. DNS servers can increase the buffer size through EDNS0 extension, and retry over TCP if that wasn't enough.
DNS server should truncate response if it doesn't fit in the buffer, and set TC (Truncate) bit, then DNS client should retry over TCP.

1220 value for UDP buffer size was chosen based on this recommendation: https://www.isc.org/blogs/dns-flag-day-2020-2/

This changes only TXT request, I left other methods untouched. But it would make sense to do the same logic for all requests, by building some small abstraction around miekg/dns for requests.

Also see docs for Exchange function:
https://pkg.go.dev/github.com/miekg/dns#Client.Exchange

Was originally found in
#536 (comment)

@kanashimia
Copy link
Contributor Author

References letsencrypt/challtestsrv#35
challtestsrv would also need to be updated, although there isn't a strict requirement on it here,
if TC bit isn't set pebble just wont retry.

@jsha
Copy link
Contributor

jsha commented Feb 17, 2026

Thanks for the patch! I'd say let's simplify and always query over TCP for all query types rather than have a fallback. We know what the backend will be in the default config and we know it supports TCP. Also RFC 9210:

recursive servers MUST support and service both TCP and UDP queries

@kanashimia
Copy link
Contributor Author

I'd say let's simplify and always query over TCP for all query types rather than have a fallback

Yeah you are right, that would be ok here too, and is a much simpler change, updated the PR.

recursive servers MUST support and service both TCP and UDP queries

obligatory mention of http://dnsneedsfuckingtcp.info heheh 😄

@kanashimia kanashimia changed the title Retry over TCP if TC bit is set for DNS TXT records and set EDNS0 Always query DNS records over TCP instead of UDP Feb 17, 2026
@kanashimia
Copy link
Contributor Author

oh, I committed a binary, sorry

TXT records can be quite large, with is a problem for DNS challenges,
they don't fit in the 512 buffer especially if there are multiple.
DNS servers can increase the buffer size through EDNS0 extension,
and retry over TCP if that wasn't enough.

For the pebble purposes there isn't much reason to try UDP first,
it is possible to just always query DNS records over TCP, so we do.

Was originally found in
letsencrypt#536 (comment)
@jsha jsha merged commit b29f2f5 into letsencrypt:main Feb 17, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments