Samba not restarting during unattended-upgrades

Ubuntu Version:
24.04 LTS

Desktop Environment (if applicable): command line only

Problem Description:
Samba is running on my Ubuntu 24.04 server.

My configuration is set to:

interfaces = 127.0.0.0/8 lan0

bind interfaces only = yes

This is necessary because Samba should be only available on one of the two interfaces.

Until recently, everything worked without errors. However, recently it stopped working – if Samba is restarted during unattended upgrades, nmbd.service doesn’t start (message: “nmbd.service: start operation timed out. Terminating.”).

Systemctl status nmbd.service then shows, among other things:

Status: “nmbd: No local IPv4 non-loopback interfaces available, waiting for interface…”

This only happens during unattended upgrades – starting Samba at system startup or manually restarting nmbd works without any problems.

In addition to nmbd, kea-dhcp4-server sometimes fails to restart properly, too.

Does anyone have any idea what might be causing this and how to fix it?

This maybe:
https://askubuntu.com/questions/1125678/ubuntu-18-04-nmbd-service-will-not-start

Seems you need to specify the interface name

$ ip -4 a

.

.

.

3: lan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
altname enp5s0f1
inet 192.168.0.2/24 brd 192.168.0.255 scope global lan0
valid_lft forever preferred_lft forever

/etc/samba/smb.conf:

interfaces = 127.0.0.0/8 lan0

bind interfaces only = yes

So interface name is OK.

I think it must be something like systemd: Only start samba and nmbd when network interfaces are up · samba-team/samba@0e57105 · GitHub ,

but not in systemd. This time the bug is in unattended-upgrades (or in apt) and I have no idea what to do about it.