[Dnsmasq-discuss] RFC 9096: Persisting constructed IPv6 RA prefixes across dnsmasq restarts
Simon Kelley
simon at thekelleys.org.uk
Mon Nov 2 09:48:30 UTC 2026
Storing constructed contexts in the lease file, and setting the
CONTEXT_OLD flag when re-reading them on startup would probably solve
this. If the prefix is still live, there's already code which undoes the
CONTEXT_OLD flag, and if not, there's code when advertises the prefix as
deprecated for a time and then deletes it, which is the desired behaviour.
One possible difficulty is the race between a reboot/dnsmasq restart and
a previously prefix appearing on an interface: It would be good to
avoid dnsmasq advertising it's previous prefixes as deprecated them
moment it starts up and then finding that they are, in fact, still valid.
The format of the lease file is somewhat obscure and not well
documented, as a result of starting off without provision for extension.
It is, however, now extensible to new fields if you know what you're
doing, eg. the code to store vendorclass information.
Simon.
On 02/11/2026 06:59, tabalugadreieck--- via Dnsmasq-discuss wrote:
> Hi all,
>
> I would like to discuss a possible improvement to dnsmasq's handling of
> dynamically constructed IPv6 prefixes across daemon restarts,
> particularly in connection with RFC 9096 Section 3.5.
>
> I have reproduced a situation where a router reboot results in clients
> retaining obsolete, preferred IPv6 addresses because the previously
> advertised prefix is no longer included in Router Advertisements after
> dnsmasq restarts.
>
> Environment
>
> dnsmasq 2.93 on OPNsense 26.7.7 (FreeBSD)
> PPPoE WAN with DHCPv6-PD, dynamically delegated /56
> LAN /64 derived from the delegated prefix
> dnsmasq provides Router Advertisements using constructor
> IPv6 SLAAC with stateless DHCPv6
>
> Relevant configuration:
>
> dhcp-range=tag:re0,::1000,::2000,constructor:re0,ra-stateless,64,1800
> ra-param=re0,60,1200
>
>
> 1. Problem: prefix change across a reboot
>
> My ISP often assigns a different delegated IPv6 prefix after a PPPoE
> reconnect or router reboot.
>
> On October 14, I captured Router Advertisements continuously on a Linux
> client while rebooting OPNsense.
>
> The relevant sequence was:
>
> 23:16:04 RA advertising old prefix A/64
> preferred=1800, valid=1800
>
> 23:16:14 Router shutdown:
> old IPv6 address removed from LAN interface
> old delegated /56 removed
>
> 23:17:33 Router starts:
> new delegated prefix B/56 received
>
> 23:17:36 dnsmasq starts
> 23:17:36 First RA advertising new prefix B/64
> preferred=1800, valid=1800
>
> 23:17:45 RA advertising prefix B/64
> 23:17:58 RA advertising prefix B/64
> ...
> 23:21:19 RA advertising prefix B/64
>
> No RA containing prefix A with preferred lifetime zero was received
> during the capture, and all subsequent RAs advertised only prefix B.
>
> Consequently, clients continued to consider their obsolete IPv6
> addresses preferred until the previously advertised lifetimes expired.
>
> On Linux, an obsolete global IPv6 address was selected for outgoing
> connections even though an address belonging to the new prefix and a
> valid default route were available. This caused IPv6 connections to
> fail. Explicitly selecting the new source address worked.
>
> The original configuration used 86400-second lifetimes, making the
> problem particularly severe. Reducing the lifetimes to 1800 seconds
> mitigates it but does not address the underlying problem.
>
> The affected client also retained an old stateful DHCPv6 address from an
> earlier configuration. That is a separate stale-binding issue; the
> request here focuses primarily on SLAAC prefix information in RAs.
>
>
> 2. Controlled experiment: live removal works correctly
>
> Following a suggestion from the OPNsense maintainers, I tested the same
> mechanism without restarting dnsmasq.
>
> I temporarily added a second IPv6 prefix to the constructor interface:
>
> ifconfig re0 inet6 fd92:4b13:6d77:5::1 prefixlen 64 alias
>
> dnsmasq started advertising this prefix alongside the existing global
> prefix.
>
> I subsequently removed the address:
>
> ifconfig re0 inet6 fd92:4b13:6d77:5::1/64 delete
>
> The packet capture showed:
>
> 13:19:50 fd92:4b13:6d77:5::/64
> valid=1800, preferred=1800
>
> 13:20:09 fd92:4b13:6d77:5::/64
> valid=1799, preferred=0
>
> 13:20:18 fd92:4b13:6d77:5::/64
> valid=1790, preferred=0
>
> 13:20:23 fd92:4b13:6d77:5::/64
> valid=1785, preferred=0
>
> 13:20:30 fd92:4b13:6d77:5::/64
> valid=1778, preferred=0
>
> The dnsmasq process ID remained unchanged throughout the test.
>
> This confirms that dnsmasq correctly detects the removal of a
> constructed prefix during normal operation and sends repeated
> deprecation RAs.
>
> As far as I understand the source code, this is handled through
> CONTEXT_OLD in dhcp6.c and radv.c.
>
> However, these old-prefix contexts appear to be maintained only in
> process memory. After a complete restart, dnsmasq no longer knows which
> prefixes it advertised previously.
>
>
> 3. RFC 9096 and possible persistent prefix history
>
> RFC 9096 Section 3.5 explicitly addresses this situation, including
> router crashes and reboots:
>
> https://www.rfc-editor.org/rfc/rfc9096#section-3.5 <https://www.rfc-
> editor.org/rfc/rfc9096#section-3.5>
>
> For dynamically learned prefixes, it recommends retaining previously
> advertised PIO prefixes and their A/L flags in stable storage.
>
> When a prefix becomes stale, the router must advertise it with both
> Preferred and Valid Lifetimes set to zero, preserving the original A/L
> flags, for at least the previously advertised valid lifetime.
>
> It seems to me that dnsmasq could potentially implement this without
> needing information from the WAN DHCPv6 client.
>
> Since dnsmasq already constructs and advertises the LAN prefixes, it
> knows exactly which PIOs it has sent.
>
> A possible approach would be to persist sufficient information about
> previously advertised constructed prefixes, including interface, prefix,
> A/L flags and relevant lifetimes.
>
> When dnsmasq starts, this information could be reloaded and compared
> with the prefixes currently constructed from interface addresses,
> accounting for interfaces that may not yet have acquired their IPv6
> addresses during startup.
>
> Any previously advertised prefixes that have become stale could then be
> advertised with Preferred and Valid Lifetimes of zero.
>
> These stale-prefix advertisements would need to continue for the
> required period, including across additional daemon or system restarts.
>
> If a previously advertised prefix becomes current again, for example
> because the ISP reassigns the same prefix, dnsmasq could stop
> deprecating it and resume advertising it normally.
>
> The existing CONTEXT_OLD implementation already seems to provide much of
> the necessary advertisement functionality; the missing component would
> primarily be durable prefix history and its restoration after startup.
>
> A configurable state-file path might be useful because some embedded
> routers and firewalls use RAM-backed directories. Ideally, the
> implementation would minimize unnecessary writes to flash storage.
>
> I also noticed that the existing live deprecation mechanism retains a
> decreasing, nonzero Valid Lifetime, whereas RFC 9096 specifies zero for
> both lifetimes when withdrawing stale prefixes.
>
>
> 4. Questions for upstream
>
> I found an older discussion from July 2013 about retaining previous
> constructor prefixes:
>
> https://lists.thekelleys.org.uk/pipermail/dnsmasq-
> discuss/2013q3/007385.html <https://lists.thekelleys.org.uk/pipermail/
> dnsmasq-discuss/2013q3/007385.html>
>
> At the time, the expectation seemed to be that the DHCPv6 client would
> retain obsolete prefixes on the interface with their preferred lifetime
> set to zero.
>
> However, this does not necessarily help after a complete system restart
> where the old interface configuration has already disappeared and the
> newly started DHCPv6 client receives a different prefix.
>
> My questions are:
>
> Would persistent history of advertised RA prefixes be a reasonable
> feature to implement directly in dnsmasq?
>
> Is there already work underway to address RFC 9096 Section 3.5, or a
> preferred alternative approach?
>
> Would such a feature fit the existing constructor architecture, or do
> you see a technical reason why the persistence should instead be handled
> by the surrounding router software?
>
> The complete reproduction and the discussion with the OPNsense
> maintainers are available here:
>
> https://github.com/opnsense/core/issues/11028 <https://github.com/
> opnsense/core/issues/11028>
>
> I can provide additional packet captures and logs, and would be happy to
> test a proposed implementation on my OPNsense system.
>
> Thanks for your work on dnsmasq and for considering this.
>
> Best regards
>
> _______________________________________________
> Dnsmasq-discuss mailing list
> Dnsmasq-discuss at lists.thekelleys.org.uk
> https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss
More information about the Dnsmasq-discuss
mailing list