I have a OpenWrt router with configured Wireguard VPN server. Is there a way to configure internal DNS domain name which is working only when VPN client connects to the VPN server. I have internal server which I want to access using somedomainname.com only internally when I’m connected to the VPN. Any way to configure this custom DNS name in Wireguard or OpenWrt?
On the WireGuard client you set the DNS server which is used when your client is connected.
On my WireGuard clients I specify the router as DNS server which is then used by the connected clients and thus also resolve local addresses.
If you are using DNSMasq make sure that DNSMasq can actually process queries from your clients.
DNSmasq has to listen on all interfaces so also on the WG interface, by default this is the case but if you changed that then you have to add the WG interface as listen interface.
Furthermore DNSMasq has to answer non local requests.
For this disable Local Service only (DNSMasq: -local-service):
Luci DNS-DHCP > Filter >Local service only : untick/disable,
or in /etc/config/dhcp > config dnsmasq:
option localservice '0'
Add forwarding to network/dhcp and dns in format
/domain.org/1.1.1.1
/domain.org/1.0.0.1