Wireguard and static IP on RPi4 B

First things first, total Linux / RPi / DietPi newbie here. Background is public safety enterprise IT, but all Windows.

Recently discovered Wireguard and DietPi. Got everything up and running until I tried setting a static IP on my RPi4 B using dietpi-config. It immediately broke Wireguard. I tried setting the static before installing wireguard and after the install, neither worked.

With the static IP in place wireguard failed to load at startup and I got the following results from “systemctl status wg-quick@wg0.service”. If I revert back to DHCP it loads fine. Currently running with a DHCP reservation at the router so all is working, just figured it might bite someone else?

Process: 552 ExecStart=/usr/bin/wg-quick up wg0 (code=exited, status=255/EXCEPTION)
Main PID: 552 (code=exited, status=255/EXCEPTION)

Sep 08 20:34:03 DietPi wg-quick[552]: [#] wg setconf wg0 /dev/fd/63
Sep 08 20:34:03 DietPi wg-quick[552]: [#] ip -4 address add 10.9.0.1/24 dev wg0
Sep 08 20:34:03 DietPi wg-quick[552]: [#] ip link set mtu 1420 up dev wg0
Sep 08 20:34:03 DietPi wg-quick[552]: [#] sysctl net.ipv4.conf.wg0.forwarding=1 net.ipv4.conf.$(sed -n 3p /DietPi/dietpi/.network).forwarding=1
Sep 08 20:34:03 DietPi wg-quick[552]: net.ipv4.conf.wg0.forwarding = 1
Sep 08 20:34:03 DietPi wg-quick[552]: sysctl: cannot stat /proc/sys/net/ipv4/conf/NONE/forwarding: No such file or directory
Sep 08 20:34:03 DietPi wg-quick[552]: [#] ip link delete dev wg0
Sep 08 20:34:04 DietPi systemd[1]: wg-quick@wg0.service: Main process exited, code=exited, status=255/EXCEPTION
Sep 08 20:34:04 DietPi systemd[1]: wg-quick@wg0.service: Failed with result ‘exit-code’.
Sep 08 20:34:04 DietPi systemd[1]: Failed to start WireGuard via wg-quick(8) for wg0.

Your error is literally in red dude… It’s self explanatory.

Thanks for the reply, but I fear it wasn’t very helpful…

#1 It’s red because I made it red to draw attention to it.
#2 If I knew what was causing that file / directory to disappear by my setting a static IP, and why it is magically no longer missing after reverting to DHCP, I wouldn’t have reached out for help.

There is a clear error in your .config. The directory is missing. You could try creating it as perhaps it isn’t made automatically. If other things are missing then you need to check those too.

If this is too hard to set up on your own I recommend a guide from Youtube e.g.

https://www.youtube.com/watch?v=n00ayGUdCaI

or even

https://www.youtube.com/watch?v=Q6pR_JEMRQA

dregilley
Okay the issue is that the servers active network interface is estimated via sed -n 3p /DietPi/dietpi/.network. This file is created on boot and updated when you change network settings. The active interface is estimated by checking ip a for the first eth or wlan interface that has an IP assigned and shows status “UP”. However this is probably not the best method, ip r s 0.0.0.0/0 is probably better to get the interface that is used for the default route. However the prior method should usually work.

So please paste: ip a s eth0 (if you use Ethernet, otherwise wlan0)
It should show an IP and the word “UP” somewhere as state. We recognised Rock64 and RockPro64 boards currently always show “UNKNOWN” there due to an kernel/firmware bug, however never found this on RPi.
If IP and “UP” are there, please run:

/DietPi/dietpi/func/obtain_network_details
systemctl restart wg-quick@wg0

It should start then.