I have setup Wireguard successfully, means I can enable a tunnel using either
sudo wg-quick up ivpn-sui or
sudo systemctl start wg-quick@ivpn-sui.
After enabling service autostart with
sudo systemctl enable wg-quick@ivpn-sui and rebooting the device I get this error:
osmc@osmc:~$ sudo systemctl status wg-quick@ivpn-sui
* email@example.com - WireGuard via wg-quick(8) for ivpn/sui
Loaded: loaded (/lib/systemd/system/wg-quick@.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2022-11-25 02:06:04 CET; 15s ago
Process: 2609 ExecStart=/usr/bin/wg-quick up ivpn-sui (code=exited, status=1/FAILURE)
Main PID: 2609 (code=exited, status=1/FAILURE)
Nov 25 02:06:02 osmc systemd: Starting WireGuard via wg-quick(8) for ivpn/sui...
Nov 25 02:06:02 osmc wg-quick: [#] ip link add ivpn-sui type wireguard
Nov 25 02:06:03 osmc wg-quick: [#] wg setconf ivpn-sui /dev/fd/63
Nov 25 02:06:04 osmc wg-quick: Name or service not known: `ch1.wg.ivpn.net:2049'
Nov 25 02:06:04 osmc wg-quick: Configuration parsing error
Nov 25 02:06:04 osmc wg-quick: [#] ip link delete dev ivpn-sui
Nov 25 02:06:04 osmc systemd: firstname.lastname@example.org: Main process exited, code=exited, status=1/FAILURE
Nov 25 02:06:04 osmc systemd: email@example.com: Failed with result 'exit-code'.
Nov 25 02:06:04 osmc systemd: Failed to start WireGuard via wg-quick(8) for ivpn/sui.
This error is clearly pointing to failed name resolution of ch1.wg.ivpn.net.
I could replace the hostname with its IP in /etc/wireguard/ivpn-sui.conf, line
Endpoint = 22.214.171.124:2049, but I would like to fix the issue when using line
Endpoint = ch1.wg.ivpn.net:2049.
Can you please advise how to fix this?
For estisk, haveing a human name, I would add it to hosts file,
If you want it dynamically, I’m sure someone more refreshed on “How to solve it with conman”, can answer.
The issue with using IP, and this includes adding it to /etc/hosts, is that this fails if provider changes IP of FQDN (ch1.wg.ivpn.net).
And just to be clear:
There’s no general issue with conman, systemd-resolved, wireguard, wg-quick or any other network related tool.
The issue is only when enabling wg-quick autostart and using FQDN in wireguard’s config
Assuming it could be a dependency issue that at the time of your WG start the DNS resolution hasn’t started.
Haven’t got wireguard up and running right now, but could this be a solution for you. Since I dont really understand the problem?
With systemd-resolved, however, instead of using that
DNS setting, add the following
PostUp command to the
[Interface] section of your WireGuard config file:
PostUp = resolvectl dns %i 126.96.36.199 188.8.131.52; resolvectl domain %i ~.
When you start your WireGuard interface up, this command will direct systemd-resolved to use the DNS server at
184.108.40.206 (or at
220.127.116.11 is not available) to resolve queries for any domain name.
Have you installed resolvconf as part of the wireguard? If so I suggest purging and using openresolv instead.
I installed opensresolv, and this works well with
wg-quick to enable/disable wireguard tunnel manually.
Again, there’s no general issue with the setup.
The only issue is with autostart service
wg-quick@ivpn-suiusing a hostname in wireguard config file.
This was my first conclusion, too.
However, the relevant service
wg-quick@ivpn-sui is using default configuration to be started after network:
Description=WireGuard via wg-quick(8) for %I
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)'
This issue is discussed here, too.
In my opinion the solution would be a
for conman because this is the only network manager service installed on OSMC.
connman-wait-for-network.service wg-quick autostart is working w/o problems and wg tunnel is established.