Wireguardサービスは起動時に「非アクティブ(死)」状態です。

Wireguardサービスは起動時に「非アクティブ(死)」状態です。

システムにインストールされたWireguardを使用してUbuntu 21.04を実行するRaspberry Pi 4があります。起動時に正しく起動しません。以前はUbuntu 20.10をインストールしましたが、同じ状況が発生しました。

始めに:

$ systemctl status [email protected][email protected] - WireGuard via wg-quick(8) for wg0
     Loaded: loaded (/lib/systemd/system/[email protected]; disabled; vendor preset: enabled)
     Active: inactive (dead)
       Docs: man:wg-quick(8)
             man:wg(8)
             https://www.wireguard.com/
             https://www.wireguard.com/quickstart/
             https://git.zx2c4.com/wireguard-tools/about/src/man/wg-quick.8
             https://git.zx2c4.com/wireguard-tools/about/src/man/wg.8

実行中のシステムでは:

$ systemctl start [email protected]

$ systemctl status [email protected][email protected] - WireGuard via wg-quick(8) for wg0
     Loaded: loaded (/lib/systemd/system/[email protected]; disabled; vendor preset: enabled)
     Active: active (exited) since Wed 2021-06-09 12:52:16 PDT; 2s ago
       Docs: man:wg-quick(8)
             man:wg(8)
             https://www.wireguard.com/
             https://www.wireguard.com/quickstart/
             https://git.zx2c4.com/wireguard-tools/about/src/man/wg-quick.8
             https://git.zx2c4.com/wireguard-tools/about/src/man/wg.8
    Process: 2366 ExecStart=/usr/bin/wg-quick up wg0 (code=exited, status=0/SUCCESS)
   Main PID: 2366 (code=exited, status=0/SUCCESS)

Jun 09 12:52:15 pi4 systemd[1]: Starting WireGuard via wg-quick(8) for wg0...
Jun 09 12:52:15 pi4 wg-quick[2366]: [#] ip link add wg0 type wireguard
Jun 09 12:52:16 pi4 wg-quick[2366]: [#] wg setconf wg0 /dev/fd/63
Jun 09 12:52:16 pi4 wg-quick[2366]: [#] ip -4 address add 10.9.0.1/24 dev wg0
Jun 09 12:52:16 pi4 wg-quick[2366]: [#] ip link set mtu 1420 up dev wg0
Jun 09 12:52:16 pi4 wg-quick[2366]: [#] iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
Jun 09 12:52:16 pi4 wg-quick[2366]: [#] ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
Jun 09 12:52:16 pi4 systemd[1]: Finished WireGuard via wg-quick(8) for wg0.

$ cat /lib/systemd/system/[email protected]
[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

[Install]
WantedBy=multi-user.target

答え1

サービスが無効になっているようです。

$ systemctl status [email protected][email protected] - WireGuard via wg-quick(8) for wg0
     Loaded: loaded (/lib/systemd/system/[email protected]; disabled; vendor preset: enabled)
                                                            ^^^^^^^^-- here

...アクティブ化:

sudo systemctl enable [email protected]

関連情報