[systemd-devel] systemd-networkd-wait-online doesn't wait for DNS

Adam Nielsen a.nielsen at shikadi.net
Sun Dec 8 12:53:54 UTC 2024


> > Is there a way to tell the systemd-networkd-wait-online service to wait
> > until DNS is working before continuing?  
> 
> There is not, so I built a small tool for this: https://forge.km6g.us/km6g/wait-for-dns
> 
> It doesn't just wait for a DNS resolver to be configured, it waits for a name to be resolvable.

Very nice!  Stealing your idea I tried doing a cut down version of it
as a systemd service and that worked too:

  # /etc/systemd/system/wait-for-dns at .service
  # systemctl enable wait-for-dns at example.com.service
  [Unit]
  Description=Wait for DNS to be up
  Before=network-online.target

  # At once a second, give up after this many seconds.
  StartLimitBurst=10

  [Service]
  Type=oneshot
  ExecStart=host %i
  Restart=on-failure
  RestartSec=1

  [Install]
  WantedBy=network-online.target

This does throw up errors during the boot process about the service
failing but if you can live with that, after 2-3 attempts it "starts"
successfully and then everything proceeds as normal.

Now my services running off NFS mounts actually start at bootup!

Cheers,
Adam.


More information about the systemd-devel mailing list