Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 Oct 2025 12:17:35 -0400
From:      David Horn <dhorn2000@gmail.com>
To:        freebsd-current@freebsd.org
Subject:   bridge and async dhcp in rc.conf
Message-ID:  <CAG7WopnG-sioD-YoGhP3JjdugFUztm2ZpxzcEbiq%2B%2BG9niZZ7g@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
--000000000000fb8b510640e45fbb
Content-Type: text/plain; charset="UTF-8"

I seem to have run into a corner case with bridge support and DHCP that
seems to have a trivial fix.

Using bridge0 with an upstream interface (em0) does not allow me to do
normal rc.conf entries for DHCP to the bridge interface (em0 is not allowed
to get addresses since it is a member of the bridge)  I use dual-stack
IPv4/IPv6 everywhere as well.  I found an example here:
https://wiki.freebsd.org/crest/the-correct-way-to-configure-bridges-in-freebsd-for-ipv6-and-ipv4
that did not work for me.  I checked the handbook documentation here:
https://docs.freebsd.org/en/books/handbook/advanced-networking/#network-bridging
and there are no examples for bridge DHCP on boot using /etc/rc.conf.
Please consider added example once this fix lands.

Example /etc/rc.conf config:

ifconfig_em0="up -tso -vlanhwtso"
cloned_interfaces="bridge0"
create_args_bridge0="addm em0 edge em0"
ifconfig_bridge0="up DHCP"
ifconfig_bridge0_ipv6="inet6 auto_linklocal accept_rtadv -ifdisabled"
rtsold_enable="yes"
rtsold_flags="-i -m bridge0"

The /etc/rc.conf interface variable "DHCP" normally is used to define for
the /etc/rc.d startup scripts and devd rules to automatically provide async
DHCP for interfaces at "LINK_UP" events.  When debugging this, I noticed
that this does not work as expected with bridge interfaces, but does with
ethernet and 802.11 interfaces.   I temporarily used "SYNCDHCP" for this
interface config and worked around the problem until my curiosity got the
best of me to debug further.

Looking at /etc//devd/dhclient.conf, I noticed that only two media-types
are supported for async DHCP on LINK_UP.  I added a third media type to
this configuration file for bridge and it started working for me.

Glad to put in a PR with a proposed patch for this, but the real question
is are there OTHER media types that should be supported with async DHCP
configurations automatically besides bridge via devd rules ?  Does this
also impact LAGG ?

Index: /etc/devd/dhclient.conf
===================================================================
--- /etc/devd/dhclient.conf (stock)
+++ /etc/devd/dhclient.conf (local)
@@ -12,6 +12,13 @@
 };

 notify 0 {
+        match "system"          "IFNET";
+        match "type"            "LINK_UP";
+        media-type              "bridge";
+        action "service dhclient quietstart $subsystem";
+};
+
+notify 0 {
        match "system"          "IFNET";
        match "type"            "LINK_UP";
        media-type              "802.11";

--Thanks!
-_Dave H

--000000000000fb8b510640e45fbb
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I seem to have run into a corner case with bridge support =
and DHCP that seems to have a trivial fix.<div><br><div>Using bridge0 with =
an upstream interface (em0) does not allow me to do normal rc.conf entries =
for DHCP to the bridge interface (em0 is not allowed to get addresses since=
 it is a member of the bridge)=C2=A0 I use dual-stack IPv4/IPv6 everywhere =
as well.=C2=A0 I found an example here:=C2=A0<a href=3D"https://wiki.freebs=
d.org/crest/the-correct-way-to-configure-bridges-in-freebsd-for-ipv6-and-ip=
v4">https://wiki.freebsd.org/crest/the-correct-way-to-configure-bridges-in-=
freebsd-for-ipv6-and-ipv4</a> that did not work for me.=C2=A0 I checked the=
 handbook documentation here:=C2=A0<a href=3D"https://docs.freebsd.org/en/b=
ooks/handbook/advanced-networking/#network-bridging">https://docs.freebsd.o=
rg/en/books/handbook/advanced-networking/#network-bridging</a> and there ar=
e no examples for bridge DHCP on boot using /etc/rc.conf.=C2=A0 Please cons=
ider added example once this fix lands.</div><div><br></div><div>Example /e=
tc/rc.conf config:</div><div><br></div><div>ifconfig_em0=3D&quot;up -tso -v=
lanhwtso&quot;</div><div>cloned_interfaces=3D&quot;bridge0&quot;<br>create_=
args_bridge0=3D&quot;addm em0 edge em0&quot;<br>ifconfig_bridge0=3D&quot;up=
 DHCP&quot;<br>ifconfig_bridge0_ipv6=3D&quot;inet6 auto_linklocal accept_rt=
adv -ifdisabled&quot;<br>rtsold_enable=3D&quot;yes&quot;<br>rtsold_flags=3D=
&quot;-i -m bridge0&quot;<br></div><div><br></div><div>The /etc/rc.conf int=
erface variable &quot;DHCP&quot; normally is used to define for the /etc/rc=
.d startup scripts and devd rules to automatically provide async DHCP for i=
nterfaces at &quot;LINK_UP&quot; events.=C2=A0 When debugging this, I notic=
ed that this does not work as expected with bridge interfaces, but does wit=
h ethernet and 802.11 interfaces.=C2=A0 =C2=A0I temporarily used &quot;SYNC=
DHCP&quot; for this interface config and worked around the problem until my=
 curiosity got the best of me to debug further.</div><div><br></div><div>Lo=
oking at /etc//devd/dhclient.conf, I noticed that only two media-types are =
supported for async DHCP on LINK_UP.=C2=A0 I added a third media type to th=
is configuration file for bridge and it started working for me.</div><div><=
br></div><div>Glad to put in a PR with a proposed patch for this, but the r=
eal question is are there OTHER media types that should be supported with a=
sync DHCP configurations automatically besides bridge via devd rules ?=C2=
=A0 Does this also impact LAGG ?</div><div><br></div><div>Index: /etc/devd/=
dhclient.conf<br>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<br>--=
- /etc/devd/dhclient.conf (stock)<br>+++ /etc/devd/dhclient.conf (local)<br=
>@@ -12,6 +12,13 @@<br>=C2=A0};<br>=C2=A0<br>=C2=A0notify 0 {<br>+ =C2=A0 =
=C2=A0 =C2=A0 =C2=A0match &quot;system&quot; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0&quot;IFNET&quot;;<br>+ =C2=A0 =C2=A0 =C2=A0 =C2=A0match &quot;type&q=
uot; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;LINK_UP&quot;;<br>+ =C2=
=A0 =C2=A0 =C2=A0 =C2=A0media-type =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0&quot;bridge&quot;;<br>+ =C2=A0 =C2=A0 =C2=A0 =C2=A0action &quot;=
service dhclient quietstart $subsystem&quot;;<br>+};<br>+<br>+notify 0 {<br=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 match &quot;system&quot; =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0&quot;IFNET&quot;;<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 match &quot;=
type&quot; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;LINK_UP&quot;;<br=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 media-type =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0&quot;802.11&quot;;<br></div><div><br></div><div>--Thanks!<br>=
</div><div>-_Dave H</div><div><br></div><div><br></div><div><br></div></div=
></div>

--000000000000fb8b510640e45fbb--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG7WopnG-sioD-YoGhP3JjdugFUztm2ZpxzcEbiq%2B%2BG9niZZ7g>