Why do I have to restart wireguard on every reboot?

ok, this is weird.

For every reboot, wireguard does not work at all. Then I restart wireguard and it works perfectly.

I’ve seen this on multiple computers, so it’s likely something known.

I do use dns to lookup hostnames from wireguard, so it might be related to this bug.

At first, I just want to delay the startup of wireguard. Is that doable?

I’m seeing this on multiple systems, so it’s probably something related to dns.

Is there no way I can delay the startup of this service?

Yes, you can delay startup of a service, but it would be helpful to see your configuration. I run wireguard on multiple devices too without that issue.

And yes…it’s always DNS :grin:

I can’t share my config, cause it’s too unclean, but I’m seeing this on three laptops now.

I’m using no-ip, so I assume it’s not reaching ddns at startup.

Are you delaying the service?

My current solution is to make the service restart indefinitely:

  networking.wireguard.interfaces.wg0 = {
    # ...
    peers = [
      {
        # By default NixOS uses the publicKey of each peer to generate service names
        # Assign a name for each peer or we will have to escape the service names
        name = "peer1";
        # ...
      }
    ];
  };

  systemd.services."wireguard-wg0-peer-peer1" = {
    serviceConfig = { Restart = "on-failure"; RestartSec = "10s"; };
    unitConfig.StartLimitIntervalSec = 0;
  };

Another solution I know is to make a service that actually checks the internet connectivity before network-online.target is reached. Running Services After the Network Is Up

1 Like

The way I understand this code it that it has to fail, before it restarts, but do we know that it itself realizes that it has failed?:wink:

Thank you. This actually works, but I have no idea how;)

Thanks a bunch. Saves me pain.