Waiting for a bridge device to be available to start another service

, ,

I have a weird network setup at home that involves a (NetworkManager-manged, as with all my network devices) bridge device, as well as dnsmasq serving one /etc/hosts to all the devices at home for all my local hostnames.

Every time I reboot, dnsmasq fails to start, with:

dnsmasq: unknown interface br0
unknown interface br0
FAILED to start up

OK, that should be easy to solve by making dnsmasq wait for the br0 device to be initialized, right?

/etc/systemd/system/dnsmasq.service.d/override.conf has:

[Unit]
BindsTo=sys-devices-virtual-net-br0.device
After=sys-devices-virtual-net-br0.device

That didn’t resolve my problem. Every time I reboot, I have to log in and restart dnsmasq.

I’m sure I’m missing something about how systemd works, but why does this not cause systemd to wait to initialize dnsmasq until br0 is configured?

I went looking and found linux - Systemd wait for network interface to be up before running service - Unix & Linux Stack Exchange which matches what I did, so I’m guessing there has been some change (I expect for some good reason) which I need to adapt to.

(I’m on Fedora 35, updated today, but this was true on Fedora 34 and I think Fedora 33 as well.)

1 Like

Note that customizing systemd units may require some extra actions to properly apply changes:

sudo restorecon -R /etc/systemd
sudo systemctl daemon-reload

Another possible workaround is replacing bind-interfaces with bind-dynamic for Dnsmasq.

2 Likes

Thanks!

It doesn’t appear to be SELinux.

# ls -lZ /etc/systemd/system/dnsmasq.service.d/override.conf 
-rw-r--r--. 1 root root system_u:object_r:dnsmasq_unit_file_t:s0 90 Dec  4 19:53 /etc/systemd/system/dnsmasq.service.d/override.conf
# restorecon -R /etc/systemd
# ls -lZ /etc/systemd/system/dnsmasq.service.d/override.conf 
-rw-r--r--. 1 root root system_u:object_r:dnsmasq_unit_file_t:s0 90 Dec  4 19:53 /etc/systemd/system/dnsmasq.service.d/override.conf

Reloading systemctl wouldn’t tell me anything since this happens during boot, only a full reboot will show that.

Wow, I never new that existed. That worked, and really I think it’s the right solution.

Thank you so much!

2 Likes