I'm looking for tips about a problem I have been facing on my Debian 11 system.
Some context: I use an old laptop as a network router with external USB WiFi adapters, powered by Debian 11. Network configuration is handled by netplan, which takes care of creating a bridge to which the dongles and the wired cards are enslaved. Then, dnsmasq listens on the bridge and starts serving IPs to clients.
Normally, after boot everything works fine. But sometimes (about once a week) the system is unable to assign IP addresses. The logs says that dnsmasq could not start because the designated interface to listen on did not exist. This makes me think that somehow dnsmasq is started before network configuration is complete, despite its unit containing both "Requires" and "After" referring to network.target. The docs for network.target say:
Since the bridge is a virtual device, it should be created by the time network.target completes and dnsmasq should see it. However, it also depend on underlying hardware indirectly (because of the physical slave NICs). So I don't get if this is some kind of bug or expected behavior, and most of the time this setup works out of pure luck.At start-up, any configured synthetic network devices (i.e. not
physical ones that require hardware to show up and be probed,
but virtual ones like bridge devices and similar which are
created programmatically) that do not depend on any underlying
hardware should be allocated by the time this target is
reached. It is not necessary for these interfaces to also have
completed IP level configuration by the time network.target is
reached.
As a workaround, I've tried adding Before and BindsTo referring the unit representing the bridge as extensions to dnsmasq via a drop-in.