[Dnsmasq-discuss] [PATCH] man: describe IPv6 dhcp-range RA modes by the flags they set
Christopher Hall
hall.christopher88 at gmail.com
Fri Nov 20 23:52:13 UTC 2026
The man page described each RA keyword as if it selected a mode. In
the code, the RA flags come from the keyword and from whether the range
has an end address, with --enable-ra only as a fallback for ranges
without a keyword. Summarise the flags in a table, then describe what
each keyword adds:
- M and O are set for ranges with no keyword, and for keyword ranges
with an end address. ra-stateless sets O without M. Keywords can turn
DHCPv6 off but never on.
- A is set by any keyword except off-link; L is cleared by off-link;
R is set by ra-advrouter.
- Any keyword except off-link enables RA for its range without
--enable-ra.
- slaac and ra-only are synonyms, and ra-only does not disable DHCPv6
on a range with an end address.
- A keyword-less range without an end address advertises M and O but
dnsmasq has no addresses to allocate from it.
Verified against option.c, radv.c and dnsmasq.c and by capturing RAs
from 2.93.
Signed-off-by: Christopher Hall <hall.christopher88 at gmail.com>
---
Hi Simon,
The man page describes the dhcp-range RA keywords as if each keyword
selected an RA mode. In practice the flags come from two things, the
keyword and whether the range has an end address, with --enable-ra as a
fallback for ranges without a keyword. The keyword names point the
wrong way on top of that. I read option.c, radv.c and dnsmasq.c and
confirmed each case with tcpdump on 2.93. This came up while fixing
OPNsense's documentation, which got several cases wrong by following
the man page.
Part of this has come up before. In 2013 you confirmed that slaac and
ra-only have the same effect, that their bits depend on the dhcp-range,
and that the description should be re-written:
https://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2013q4/007910.html
The ra-only wording still misleads people (e.g.
https://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2023q2/016974.html),
but the problem is wider than the synonyms.
In short: the M and O flags default to on. No keyword turns DHCPv6
addressing on; keywords can only take it away (ra-stateless always
clears M, and slaac/ra-only, ra-names and ra-advrouter clear M and O
when the range has no end address). What the keywords do is turn on RA
and SLAAC for the range, and add auxiliary features (DNS names for
ra-names, router addresses for ra-advrouter). Whether dnsmasq actually
serves DHCPv6 leases depends on the end address. --enable-ra is only a
fallback for ranges without a keyword.
Rather than explain each keyword in terms of the others, the patch
summarises how dnsmasq decides the flags for a range in a four-row table
(the outcomes of the flowchart linked below), then covers what ra-names,
ra-advrouter and off-link add. I've kept the keyword names; renaming or
deprecating ra-only would arguably be clearer, but that's your call.
Captured flags (range fd00:4::1000-fd00:4::2000, /64):
enable-ra end addr keyword M O A notes
yes yes (none) 1 1 0
yes yes ra-only / slaac 1 1 1
yes yes ra-names 1 1 1
yes yes ra-stateless 0 1 1
yes yes ra-advrouter 1 1 1 R set, router addr in prefix opt
yes yes off-link 1 1 0 L clear
yes yes slaac,ra-stateless 0 1 1
yes yes ra-advrouter,off-link 1 1 1 R set, L clear
yes no ra-only / slaac 0 0 1
yes no ra-stateless 0 1 1
yes no (none) 1 1 0 no DHCPv6 replies
no yes ra-names 1 1 1 RA sent without --enable-ra
no yes off-link - - - no RA
no yes (none) - - - no RA
Flowchart, per-keyword table and full capture results:
https://github.com/opnsense/docs/issues/937
Thanks,
Christopher
man/dnsmasq.8 | 66 ++++++++++++++++++++++++++++++++++-----------------
1 file changed, 44 insertions(+), 22 deletions(-)
diff --git a/man/dnsmasq.8 b/man/dnsmasq.8
index 8923325..b24795b 100644
--- a/man/dnsmasq.8
+++ b/man/dnsmasq.8
@@ -1125,26 +1125,48 @@ for details.)
For IPv6, the mode may be some combination of
.B ra-only, slaac, ra-names, ra-stateless, ra-advrouter, off-link.
+All but
+.B off-link
+are RA keywords. Whether a range is advertised, and with which of the
+M (managed address), O (other configuration) and A (autonomous, use
+SLAAC) bits, depends on its RA keyword and on whether it has an end
+address:
-.B ra-only
-tells dnsmasq to offer Router Advertisement only on this subnet,
-and not DHCP.
+.nf
+ RA keyword end address needs --enable-ra M O A
+ none either yes 1 1 0
+ ra-stateless either no 0 1 1
+ any other yes no 1 1 1
+ any other no no 0 0 1
+.fi
+.B ra-stateless
+takes precedence when combined with other keywords. A
+.B static
+range counts as having an end address.
.B slaac
-tells dnsmasq to offer Router Advertisement on this subnet and to set
-the A bit in the router advertisement, so that the client will use
-SLAAC addresses. When used with a DHCP range or static DHCP address
-this results in the client having both a DHCP-assigned and a SLAAC
-address.
+and
+.B ra-only
+are synonyms; despite its name,
+.B ra-only
+does not stop DHCPv6 on a range with an end address.
-.B ra-stateless
-sends router advertisements with the O and A bits set, and provides a
-stateless DHCP service. The client will use a SLAAC address, and use
-DHCP for other configuration information.
+dnsmasq allocates DHCPv6 addresses only from a range with an end
+address and without
+.B ra-stateless,
+or to
+.B --dhcp-host
+entries in a
+.B static
+range. A range with no RA keyword and no end address is still
+advertised with M set, so clients get a global address only if another
+DHCPv6 server answers on the link.
+
+M and O apply to the whole advertisement on an interface, and are set
+if any range advertised there sets them.
.B ra-names
-enables a mode
-which gives DNS names to dual-stack hosts which do SLAAC for
+additionally gives DNS names to dual-stack hosts which do SLAAC for
IPv6. Dnsmasq uses the host's IPv4 lease to derive the name, network
segment and MAC address and assumes that the host will also have an
IPv6 address calculated using the SLAAC algorithm, on the same network
@@ -1152,20 +1174,15 @@ segment. The address is pinged, and if a reply is received, an AAAA
record is added to the DNS for this IPv6
address. Note that this is only happens for directly-connected
networks, (not one doing DHCP via a relay) and it will not work
-if a host is using privacy extensions.
-.B ra-names
-can be combined with
-.B ra-stateless
-and
-.B slaac.
+if a host is using privacy extensions.
.B ra-advrouter
-enables a mode where router address(es) rather than prefix(es) are included in the advertisements.
+additionally includes router address(es) rather than prefix(es) in the advertisements, and sets the R bit.
This is described in RFC-3775 section 7.2 and is used in mobile IPv6. In this mode the interval option
is also included, as described in RFC-3775 section 7.3.
.B off-link
-tells dnsmasq to advertise the prefix without the on-link (aka L) bit set.
+clears the on-link (aka L) bit, and does not otherwise change the table.
.TP
.B \-G, --dhcp-host=[<hwaddr>][,id:<client_id>|*][,set:<tag>][,tag:<tag>][,<ipaddr>][,<hostname>][,<lease_time>][,ignore]
@@ -2208,6 +2225,11 @@ the machine running dnsmasq. By default, the "managed address" bits are set, and
the "use SLAAC" bit is reset. This can be changed for individual
subnets with the mode keywords described in
.B --dhcp-range.
+Those keywords (except
+.B off-link)
+also enable advertisements for their own subnet without this option;
+.B --enable-ra
+is needed only for ranges with no RA keyword.
RFC6106 DNS parameters are included in the advertisements. By default,
the relevant link-local address of the machine running dnsmasq is sent
as recursive DNS server. If provided, the DHCPv6 options dns-server and
--
2.56.1
More information about the Dnsmasq-discuss
mailing list