Fifth and hopefully final part of the NAS configuration. The main part, anyway. The problem with the VPN connection has been solved... in a really weird way, but it works.
I tried many solutions and it always worked weird. Each time I set up the working solution and tested it, it looked good. I also shut down the server, waited a minute, restarted and the VPN still worked. However, the next day when I rebooted, the VPN was down again. I went through this loop many times.
But finally I found a solution. I have three scripts running after startup. The first one kills the running wireguard instance and saves an iptables configuration. The second flushes all iptables configurations and restarts wireguard. The last one then restores the iptables rules and restarts the firewall. Then it works. I cannot see why the firewall is behaving this way, but at least it works.
Jan "Jenkings" Škoda - blog
Simplifying IT, Amplifying Knowledge