WireGuard / wireguard-vyatta-ubnt

WireGuard for Ubiquiti Devices
https://www.wireguard.com/
GNU General Public License v3.0
1.45k stars 68 forks source link

UDR Unsupported Kernel #108

Closed lukekenny closed 2 years ago

lukekenny commented 2 years ago

Package version

1.0.20210606-3

Firmware version

2.3.7

Device

Unifi Dream Machine (Pro / SE) - UDM

Issue description

On a UDR, this works fine when running the setup-wireguard.sh script from the CLI

However, when configuring it to load on boot as per the instructions, it doesn't work, and systemctl status setup-wireguard shows the error:

Unsupported Kernel version 4.4.198-ui-mtk

Configuration and log output

root@udr:~# systemctl status setup-wireguard
● setup-wireguard.service - Run wireguard setup script
   Loaded: loaded (/etc/systemd/system/setup-wireguard.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Wed 2021-12-15 15:27:41 AEDT; 23min ago
 Main PID: 3190 (code=exited, status=0/SUCCESS)
      CPU: 61ms

Dec 15 15:27:41 udr systemd[1]: Starting Run wireguard setup script...
Dec 15 15:27:41 udr setup_wireguard.sh[3190]: loading wireguard...
Dec 15 15:27:41 udr setup_wireguard.sh[3190]: Unsupported Kernel version 4.4.198-ui-mtk
Dec 15 15:27:41 udr systemd[1]: setup-wireguard.service: Succeeded.
Dec 15 15:27:41 udr systemd[1]: Started Run wireguard setup script.
Dec 15 15:27:41 udr systemd[1]: setup-wireguard.service: Consumed 61ms CPU time.
peacey commented 2 years ago

Hi @lukekenny,

You are using the UDR, correct? Can you please confirm that you only installed the WireGuard package to /data/wireguard and not /mnt/data/wireguard? If it's in both folders, it will cause an error.

Make sure you installed it to /data, then delete any installation in /mnt/data and restart the systemd service.

rm -rf /mnt/data/wireguard
rm -rf /etc/wireguard
systemctl restart setup-wireguard
systemctl status setup-wireguard

Check what the status says in the end.

lukekenny commented 2 years ago

Confirming there is no /mnt/data/wireguard directory (there is not even a /mnt/data directory,) and the package has been installed in /data/wireguard. Confirming this is an early access UDR, not a UDM, UDM-Pro or UDM-SE.

After removing /etc/wireguard, if I use systemctl restart setup-wireguard, it appears to work, however it creates /etc/etc/wireguard, and a links /etc/wireguard to /etc/etc/wireguard, and wg-quick is not found when I try to execute it.

If I delete those /etc/wireguard and /etc/etc/wireguard directories again and run the script directly, the link /etc/wireguard is linked to /data/wireguard/etc/wireguard, and wg-quick works.

Rebooting either after deleting the directories, or after deleting the directories then manually running the script, leads to the same kernel mismatch error.

peacey commented 2 years ago

Thanks @lukekenny. The startup service didn't work as expected. Can you try to use this setup-wireguard.service instead?

[Unit]
Description=Run wireguard setup script
Wants=network.target
After=network.target

[Service]
Type=oneshot
ExecStart=sh -c 'WGDIR="$(find /mnt/data/wireguard /data/wireguard -maxdepth 1 -type d -name "wireguard" 2>/dev/null | head -n1)"; "$WGDIR/setup_wireguard.sh"'

[Install]
WantedBy=multi-user.target

Then delete all the /etc directories to start fresh and reload the service file.

rm -rf /etc/wireguard /etc/etc/wireguard
systemctl daemon-reload
systemctl start setup-wireguard

If it works this time, restart and confirm it works as well.

lukekenny commented 2 years ago

Solution works perfectly! Thanks @peacey!

peacey commented 2 years ago

Great @lukekenny! Closing this now as issue is fixed. Please feel free to open another issue if you have more problems! Have a nice day!