It turns out that
network.target does not mean a fully functional network, just that the basic subsystem is up and running. For services that bind to the universal address
0.0.0.0 this isn’t an issue, but if it explicitly binds to an interface or IP it may fail during boot if the interface or IP isn’t available when it tries to start.
I recently had this problem with Samba. The following was in /etc/samba/smb.conf
[global] interface = eth1 bind interfaces only = yes
Which caused an error on boot
open_sockets_smbd: No sockets available to bind to.
So what we actually need is
network-online.target. This target doesn’t complete until after all configured interfaces have come up. This can make your boot slower by making DHCP a blocking step before some services, but in some cases like this one we need that extra time.
So based on my earlier post about overriding SystemD, we’ll create an override and make
smb.service also depend on
# cat /etc/systemd/system/smb.service.d/override.conf [Unit] After=network-online.target
Now Samba will start up correctly on a reboot!