After upgrading to Kubuntu 19.04, I don't know how to write a service so that it can start after DNS service has been initialized.
In this past, I just use After=network.target, but now it doesn't work. I also tried After=network-online.target, but no luck.
So I think the problem is systemd-resolved, how could I solve this problem?
update:
ERROR: getaddrinfo: Temporary failure in name resolution
ERROR: failed to resolve the provided hostnameThese are two related logs. So I can confirm the problem is related to DNS service.
71 Answer
Please add a dependency in your service file:
After=nss-lookup.targetThis should ensure that host/name lookup is operable.
Further details are in the documentation:
nss-lookup.target
A target that should be used as synchronization point for all host/network name service lookups. Note that this is independent of UNIX user/group name lookups for which nss-user-lookup.target should be used. All services for which the availability of full host/network name resolution is essential should be ordered after this target, but not pull it in. systemd automatically adds dependencies of type After= for this target unit to all SysV init script service units with an LSB header referring to the "$named" facility.
To fully wait for network, the documentation of systemd directs you to add to your service:
After=network-online.target
Wants=network-online.targetand to confirm that the relevant "wait" service is enabled:
$ systemctl is-enabled NetworkManager-wait-online.service systemd-networkd-wait-online.service
disabled
enabled 8