List the units available on your setup
systemctl list-unit-files | grep network
Two unit files exist - enable either depending on your setup
systemd-networkd-wait-online.service
NetworkManager-wait-online.service
Then add the nss-lookup.target as @raguse suggested
Wants=network-online.target
After=network-online.target
After=nss-lookup.target
Cut the crap! How do I make sure that my service starts after the network is really online?
Well, that depends on your setup and the services you plan to run after it (see above). If you need to delay you service after the network is up, include
After=network-online.target Wants=network-online.targetin the .service file.
This will ensure that all configured network devices are up and have an IP address assigned before the service is started. network-online.target will time out after 90s. Enabling this might considerably delay your boot even if the timeout is not reached.
The right “wait” service must be enabled too (NetworkManager-wait-online.service if NetworkManager is used to configure the network, systemd-networkd-wait-online.service if systemd-networkd is used, etc.). systemd-networkd.service has Also=systemd-networkd-wait-online.service in its [Install] section, so when systemd-networkd.service is enabled, systemd-networkd-wait-online.service will be enabled too, which means that network-online.target will include systemd-networkd-wait-online.service when and only when systemd-networkd.service is enabled. NetworkManager-wait-online.service is set up similarly. Verify that the right service is enabled (usually only one should be):
$ systemctl is-enabled NetworkManager-wait-online.service systemd-networkd-wait-online.service disabled enabled