I've tested Before=network-pre.target; that works fine. However, for the networkd case, systemd-networkd-wait-online.target should ensure that systemd-networkd-resolvconf-update.service has run first otherwise there might a window where interfaces are configured, but DNS is not.
The following change should go against systemd-networkd-wait-online.service
+ # Ensure that DNS is working before reaching online target
+ After=systemd-networkd-resolvconf-update.service
I've tested Before= network- pre.target; that works fine. However, for the networkd case, systemd- networkd- wait-online. target should ensure that systemd- networkd- resolvconf- update. service has run first otherwise there might a window where interfaces are configured, but DNS is not.
The following change should go against systemd- networkd- wait-online. service
+ # Ensure that DNS is working before reaching online target networkd- resolvconf- update. service
+ After=systemd-