I have a self-hosted wireguard server for my own little VPN with my different devices. Now I tried to connect Home Assistant with this server. A lot of things are easier since wireguard is an official kernel module.
I was able to start in the home assistant command line a new docker container and place the config for the client in the data mount /mnt/data/wireguard_config/
. To start the docker container I used that command:
docker run -d \
--name=wireguard \
--cap-add=NET_ADMIN \
--cap-add=SYS_MODULE \
-e PUID=1000 \
-e PGID=1000 \
-e TZ=Europe/London \
-v /mnt/data/wireguard_config:/config \
-v /lib/modules:/lib/modules \
--sysctl="net.ipv4.conf.all.src_valid_mark=1" \
--restart unless-stopped \
ghcr.io/linuxserver/wireguard
My client config looks like this:
[Interface]
Address = 10.13.13.9
PrivateKey = ************
ListenPort = 51820
DNS = 10.13.13.1
[Peer]
PublicKey = **********
Endpoint = *.*.*.*:51820
AllowedIPs = 10.13.13.0/32
The docker container starts like expected:
[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 30-config: executing...
Uname info: Linux 0b0ca16835b3 5.4.79-v8 #1 SMP PREEMPT Fri Jan 1 16:40:13 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux
**** It seems the wireguard module is already active. Skipping kernel header install and module compilation. ****
**** Client mode selected. ****
**** Disabling CoreDNS ****
[cont-init.d] 30-config: exited 0.
[cont-init.d] 99-custom-scripts: executing...
[custom-init] no custom files found exiting...
[cont-init.d] 99-custom-scripts: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[#] ip link add wg0 type wireguard
[#] wg setconf wg0 /dev/fd/63
[#] ip -4 address add 10.13.13.9 dev wg0
[#] ip link set mtu 1420 up dev wg0
[#] resolvconf -a wg0 -m 0 -x
[#] ip -4 route add 10.13.13.0/32 dev wg0
But I get no connection to the server. I tried to ping the server. But that didn’t work out either. Has anyone had a similar problem? Is there possibly a firewall that prevents the connection? Maybe because it goes via UDP instead of the more common TCP.