I'm a little confused about systemd unit dependencies

I see named.service (from the bind package) has the following

[Unit]
Description=Berkeley Internet Name Domain (DNS)
Wants=nss-lookup.target
...
Before=nss-lookup.target

Isn’t this contradictory? How can something both run before and have a dependency on another unit?

Hi,

A quick google found this:-

Regards Tom.

… a (wants) requirement dependencies do not influence the order in which services are started or stopped.” Therefore → Before

1 Like

Ah, I think it’s slightly more complicated. In this case it’s a “special target” which doesn’t itself do anything. So when named starts up it causes the “nss-lookup” target to be triggered.

Hmm, personally I think this might be a misconfig; why would an authoritative server that’s not listed in resolv.conf (or elsewhere) cause this target to be triggered. I could see it for a device that uses itself (and systemd-resolved), but not in this case. Fortunately I think it’s harmless (it might impact rpc.statd startup).