Wireguard VPN times out before the USB GSM dongle is initialised at boot

Hi, trying to get VPN Wireguard to work from a remote location on a raspberry based gateway, it seems that wireguard starts at boot before the USB is initialized. Thus it can not get my servers name resolved and times out at boot. It never restarts to get a working VPN connection once this has happened, as wireguard seems to be running without actually tunneling anything.

sudo wg show ->
transfer: 0 B received, 25.73 KiB sent
persistent keepalive: every 25 seconds

It seems to be a generic problem with Wireguard, but right now Iā€™m just logging this to go home to get something to eat. https://github.com/NixOS/nixpkgs/issues/30459

Changing a configuration line in /etc/wireguard/wg0.conf from

Endpoint = this.is.my.server.com:51820


Endpoint =

fixes this problem.
But it is not a long-term solution for me as the server is on Amazon, and it might change IP-number upon restart of that machine.

I see at least a couple viable options:

  • Reorder the start of wireguard to verify DNS is working before making the connection.
  • Use an elastic IP in AWS.
1 Like