tusc / wireguard-kmod

WireGuard for UDM series routers
https://www.wireguard.com/
352 stars 19 forks source link

wg0.conf missing. #69

Open MindfulAttorney opened 1 year ago

MindfulAttorney commented 1 year ago

I'm following the guide and for some reason the wg0.conf is missing.

When typing "cp /etc/wireguard/wg0.conf.sample /etc/wireguard/wg0.conf", I get the following error : No such file or directory.

How would I remedy this issue?

mechatroniks-git commented 1 year ago

The command will try to copy the sample file wg0.conf.sample, into the new file. So it is telling you that the directory and/or file is missing.

Try to cd into that directory, cd /etc/wireguard and type ls-la, you should see something like this:

# ls -la
total 24
drwxr-xr-x    2 avahi    avahi         4096 Aug 31 12:33 .
drwxr-xr-x    3 avahi    avahi         4096 Aug 31 12:08 ..
-rw-r--r--    1 root     root            45 Aug 31 12:33 privatekey
-rw-r--r--    1 root     root            45 Aug 31 12:33 publickey
-rw-r--r--    1 root     root           316 Aug 31 12:59 wg0.conf
-rw-r--r--    1 avahi    avahi          197 Apr 25 18:51 wg0.conf.sample
sjtuross commented 1 year ago

I got the same issue on UDM-SE. It's because the symlink for /etc/wireguard didn't get created as the folder already exists. So I removed that folder and rerun setup_wireguard.sh to solve the issue.

mwolter805 commented 1 year ago

On version 2.4.27 for the UDMP had to change setup_wireguard.sh to the following:

#!/bin/sh
# Tusc00 on reddit, @tusc69 on ubnt forums
#
# v4-7-21   Initial release. Updated script to auto load kernel module based on installed firmware version.
# v4-8-21   Build now includes iptables_raw module. This is required for wg-quick when changing routes. Switched to MUSL static library
#       for building wireguard tools and bash given the number of CVEs with glib 2.26. Preliminary support for the UXG.
# v4-10-21  Updated release to include utils such as htop, iftop and qrencode. The last one allows easy import of wireguard configs
#       into your IOS/Android WireGuard client using QR codes. 
# v6-23-21  Added support for resolvconf

# Set this to 1 to try to load the built-in wireguard module first. External module will still be loaded if built-in one doesn't exist.
# Set to 0 to only load external module.
LOAD_BUILTIN=1

DATA_DIR="."
if [ -d "/mnt/data" ]; then
    DATA_DIR="/mnt/data"
elif [ -d "/data" ]; then
    DATA_DIR="/data"
fi
WIREGUARD="${DATA_DIR}/wireguard"

ln -sf $WIREGUARD/usr/bin/wg-quick /usr/bin
ln -sf $WIREGUARD/usr/bin/wg /usr/bin
#ln -s $WIREGUARD/usr/bin/bash /bin
ln -sf $WIREGUARD/usr/bin/qrencode /usr/bin
#ln -s $WIREGUARD/usr/bin/htop /usr/bin
ln -s $WIREGUARD/usr/sbin/iftop /usr/sbin
ln -s $WIREGUARD/sbin/resolvconf /sbin

# create symlink to wireguard config folder
if [ ! -n "$(ls -A /etc/wireguard)" ]
then
   rm -rfv /etc/wireguard
   ln -sf $WIREGUARD/etc/wireguard /etc/wireguard
fi

# create symlink to resolvconf config file
if [ ! -f "/etc/resolvconf.conf" ]
then
   ln -s $WIREGUARD/etc/resolvconf.conf /etc/
fi

# required by wg-quick
if [ ! -d "/dev/fd" ]
then
   ln -s /proc/self/fd /dev/fd
fi

#load dependent modules
modprobe udp_tunnel
modprobe ip6_udp_tunnel

lsmod|egrep ^wireguard > /dev/null 2>&1
if [ $? -eq 1 ]
then
   ver=`uname -r`
   echo "loading wireguard..."
   if [ "$LOAD_BUILTIN" = "1" -a -e /lib/modules/$ver/extra/wireguard.ko ]; then
      modprobe wireguard
   elif [ -e $WIREGUARD/modules/wireguard-$ver.ko ]; then
     insmod $WIREGUARD/modules/wireguard-$ver.ko
#    iptable_raw required for wg-quick's use of iptables-restore
     insmod $WIREGUARD/modules/iptable_raw-$ver.ko
     insmod $WIREGUARD/modules/ip6table_raw-$ver.ko
   else
     echo "Unsupported Kernel version $ver"
   fi
fi