At first ninze thank you very much for your post showing a wiregard@libreelec way that can handle DNS entries instead of IP's only!
joulester #17 is actually the way you want to use.
I just want to add useful commands/information as an addition to #17. I hope it makes it easier for others to understand.
If you change /storage/.config/system.d/wg0.service and/or /storage/.config/wireguard/wg0.conf, just use the following commands for testing:
systemctl daemon-reload
systemctl stop wg0.service
systemctl start wg0.service
systemctl status wg0.service
#other helpful commands:
wg
route
ip route list
For enabling wireguard when LibreELEC starts, just do:
My goal was to use the wireguard server as a hop that redirects the traffic further (in this case to 192.168.150.0/24). On LibreELEC-side 1 additional route was needed:
ExecStart=ip route add 192.168.150.0/24 dev wg0 src 192.168.20.2
ExecStop=ip route del 192.168.150.0/24 dev wg0 src 192.168.20.2
The order was very important (Dont ask me why. Manually a different order was possible. Perhaps the speed of execution matters):
ExecStart=ip link add dev wg0 type wireguard
ExecStart=ip address add dev wg0 10.1.1.3/24
ExecStart=wg setconf wg0 /storage/.config/wireguard/wg0.conf
ExecStart=ip link set up dev wg0
ExecStart=ip route add 192.168.150.0/24 dev wg0 src 10.1.1.3
ExecStop=ip route del 192.168.150.0/24 dev wg0 src 10.1.1.3
ExecStop=ip link set down dev wg0
ExecStop=ip address del dev wg0 10.1.1.3/24
ExecStop=ip link del dev wg0
Why "ip route add ..."? It really needs to look like this:
I hope it helps.