Openvpn DNS Problem

Running Network Manager and using VPN service from Private Internet Access (PIA). Whenever VPN is connected I can no longer access other machine on the LAN via hostname. Resolv.conf list nameservers from PIA first then the local nameserver. If I edit resolv.conf and place the local nameserver first then local machines can be accessed and the VPN service works fine.

Can someone suggest a way to fix this without having to edit resolv.conf every time VPN is used?

You’re describing something which is common to all VPN.

Although you’re tunneling sessions, by default DNS is actually still pointing to your original, non-VPN DNS unless you specify explicitly in your VPN configuration to point to something else.

You didn’t describe what VPN technology you’re using… but you can do this on your own. Depending on the technology, find and configure the config file for that VPN.


Sorry forgot to include that. I am using Openvpn.

Doesn’t DNS look at each entry in resolv.conf to find the address? In other words it uses the first entry to resolve if not there then tries the next.

Not necessarily. A lot of systems won’t look further than the first DNS and maybe try the next listed only if the first is <totally> unreachable (eg offline) and in that case would have to time out before the next might be queried (which itself might cause a time out).

If the queried DNS is reachable but can’t provide a result (particularly if it’s a private Host not on the Internet), you’ll just get a failure, and another DNS will not be tried.

Inspect and edit your openvpn.conf to custom configure what you need.
If you point to your own DNS, make sure that it will also forward if the query’s result isn’t cached locally.
For a tiny network, the alternative is to add entries to your Hosts file (if you don’t want to deploy a DNS for your VPN).