Wireguard VPN connection not resolving local host names

I have setup a Wireguard VPN on my raspberry pi and I can connect to it via client app on my mobile phone. I can access the internet though the phone and I confirm that the phone is using the same IP of the raspberry pi, so the VPN is working for the outer internet.

But I have a local webserver on my Pi, which I can access on the pi using a direct internal IP (192.168.1.50), using raspberrypi.local hostname, or by using a custom host defined in /etc/hosts file.

However, in the phone and over VPN I can only access that local webserver over the internal IP: raspberrypi.local or any other hostname defined in /etc/hosts does not work.

How can I resolve this?


Solution 1:

I've indirectly solved this issue by installing Pi-Hole, setting up local hosts there and enabling it as the DNS server for all my clients. Now I can access my home network via VPN with local hostname resolution + added benefit of DNS level ad blocking.

Pi-Hole and Wireguard VPN play very nice with each other (Pi-Hole detected Wireguard and offered to do all configurations by itself).