Skip to content

Add an opt-in rfc2308_ttl mode for TTL inheritance - #1300

Open
peterthomassen wants to merge 1 commit into
rthalley:mainfrom
peterthomassen:20260906_honor_previous_TTL
Open

Add an opt-in rfc2308_ttl mode for TTL inheritance#1300
peterthomassen wants to merge 1 commit into
rthalley:mainfrom
peterthomassen:20260906_honor_previous_TTL

Conversation

@peterthomassen

Copy link
Copy Markdown
Contributor

Folks complaining about this:

Pre-RFC 2308 master files overloaded the SOA MINIMUM field to mean "default TTL for the zone". This is what dnspython does: a record with no TTL takes the SOA minimum whenever no $TTL directive has been seen. RFC 2308 section 4 removed that meaning of MINIMUM, leaving RFC 1035 section 5.1 (which says that a record without TTL inherits the most recently stated one).

This PR adds an rfc2308_ttl parameter (default False) to dns.zone.from_text(), dns.zone.from_file(), dns.zonefile.read_rrsets(), and dns.zonefile.Reader, which selects the RFC 2308 interpretation. An explicit default ($TTL or default_ttl/force_ttl) still wins in either mode, and the SOA minimum is still used as a last resort when nothing else has stated a TTL at all, so a zone whose only TTL is the SOA minimum parses identically in both modes.

How it works: the reader now tracks whether the current default TTL comes from SOA MINIMUM (default_ttl_from_soa, cleared by $TTL and saved/restored across $INCLUDE alongside the other TTL state), and the three places that resolved an missing TTL now use a single _implicit_ttl() helper instead of each open-coding the precedence. With the flag off, the resolved TTL is unchanged in every reachable state, so existing behavior is preserved.

@rthalley

rthalley commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Given how old RFC 2308 is, and that no one likely wants the old behavior, I wonder if we should look at this as a bug and make the default True, even though that will have a backwards compatibility impact, at least in theory.

@peterthomassen

Copy link
Copy Markdown
Contributor Author

Yes, that's why I was hesitating. I guess the only reason to keep the current behavior really is backwards compatibility.

I wouldn't mind making the new one the default, but I guess that would require a 2.9 release and an additional warning in the release notes or something. Your call!

@rthalley

rthalley commented Sep 7, 2026

Copy link
Copy Markdown
Owner

2.9 is coming in a week or two, so my vote is to make the proper behavior the default and add a note to whatsnew.rst.

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