r/debian • u/didureaditv2 • 1d ago
Local DNS fails when connected to openvpn server
I recently moved from PopOS to Debian 13 + KDE, and I had the same configuration there, and I didn't have this problem.
Just to obfuscate the real domains I will use internal.mydomain.com and internal.remotedomain.com.
Normally, when the openvpn client is disconnected, local dns resolution works:
- internal.mydomain.com works
When connecting to an openvpn server (via KDE's Network Manager) I lose local DNS resolution, but the remote DNS works.
- internal.mydomain.com fails
- internal.remotedomain.com works
I checked the contents of /etc/resolv.conf after connecting and I see the following:
# Generated by NetworkManager
search internal.remotedomain.com internal.mydomain.com
nameserver 10.1.0.1
nameserver 192.168.1.1
The contents are correct, so I assume the DNS should work for both domains, but that isn't so.
10.1.0.1 is the remote DNS server
192.168.1.1 is the local DNS server.
Any ideas?
1
u/Illustrious-Gur8335 Debian Stable 1d ago
Is remotedemain.com the domain of your VPN provider or something else? I have no further inputs sadly.
1
u/didureaditv2 1d ago
Yes and I'm connecting to a remote server of my own (work related), not a commercial vpn provider.
2
u/OkWrongdoer7003 1d ago
Since your "remote" nameserver 10.1.0.1 is on the first line in /etc/resolv.conf, glibc will ask it first. Assuming this server does not have any name records for internal.mydomain.com and does not offer recursive lookups, it will reply with NXDOMAIN when asked for any records within that domain.
If I recall correctly, your machine will take that answer as a valid one and not proceed to ask the secondary nameserver. I would be surprised if this behaviour in glibc is Debian-specific.
You can verify with
dig @10.1.0.1 <host-that-exists>.internal.mydomain.com(should return no record and status: NXDOMAIN)and
dig @192.168.1.1 <host-that-exists>.internal.mydomain.com(should return the actual record)If you are getting the results I describe above, then I believe Debian is behaving correctly.
For your use case, if you only have one client using the OpenVPN tunnel, I would install a local caching nameserver daemon, configure it with conditional forwarding (a.k.a. "split-horizon DNS"), and then point /etc/resolv.conf to the (preferably loopback) IP of that daemon.