Jump to content

wireguard fails to connect at boot, rk3588 (nanopi r6c)


Antonio Mignolli

Recommended Posts

Hi all, I am running armbian bookworm on a nanopi r6c (rk3588).

At boot, wireguard does not resolve the endpoint (strange, because it runs after network-online.target)

and instead of keep trying, it gives up.

If I manually restart it, all is good.

 

Attached screenshots show the different behaviour in a raspberry pi (rpi4 as hostname) running raspios,

where it keeps trying to resolve the endpoint, and nanopi r6c not retrying.

 

I will recompile kernel to enable wireguard debug (or is there a quicker way?)

 

wgforum_rpi4.png

wgforum_r6c.png

Edited by Antonio Mignolli
Attached screenshots and removed debug question.
Link to comment
Share on other sites

  • Antonio Mignolli changed the title to wireguard fails to connect at boot, rk3588 (nanopi r6c)

Exactly the same error using Radxa Zero and armbian bookworm. Like the exact same thing. 

When i manualy restart the service all is good. 

 

when i try to enable systemd-networkd-wait-online.service , the vendor preset is disabled meaning that the wg service has no way to know when the network is online :
After=network-online.target nss-lookup.target
Wants=network-online.target nss-lookup.target


any help appreciated.

Link to comment
Share on other sites

Hi all.
I solved it, indeed, by "drastically" recompile wireguard-tools with a modification (makes sense, IMHO).

https://github.com/WireGuard/wireguard-tools/pull/19

Basically, I am telling wireguard to keep trying reconnection according to configuration (environment variable WG_ENDPOINT_RESOLUTION_RETRIES),

and don't modify this behaviour when some error types occur (EAI_NONAME or EAI_FAIL).

 

I just noticed there is another modification, maybe even better, here:
https://github.com/WireGuard/wireguard-tools/pull/18

Link to comment
Share on other sites

Hello all,

 

another option is to modify the service directly to restart it automatically, here's an example provided by chat gpt :
 

[Unit]
Description=WireGuard via wg-quick(8) for %I
After=network-online.target nss-lookup.target
Wants=network-online.target nss-lookup.target
PartOf=wg-quick.target
Documentation=man:wg-quick(8)
Documentation=man:wg(8)
Documentation=https://www.wireguard.com/
Documentation=https://www.wireguard.com/quickstart/
Documentation=https://git.zx2c4.com/wireguard-tools/about/src/man/wg-quick.8
Documentation=https://git.zx2c4.com/wireguard-tools/about/src/man/wg.8

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/wg-quick up %i
ExecStop=/usr/bin/wg-quick down %i
ExecReload=/bin/bash -c 'exec /usr/bin/wg syncconf %i <(exec /usr/bin/wg-quick strip %i)'
Environment=WG_ENDPOINT_RESOLUTION_RETRIES=infinity
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

 

the restart always and restart sec makes the service restart automatically after 5 seconds if failed. this means that on boot it will fail and restart automatically after 5 seconds which might be enough time for network connection.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines