Can a Linux DNS Resolver Override Nameservers Provided by a VPN?
A VPN may hand your Linux machine a DNS server, but the resolver, the network manager and even the browser can overrule it. Here is who decides, and how to check.
10 min readUpdated Nov 11, 2026By XPASS Editorial Team

When you connect to a VPN on Linux, you might assume that every DNS question now goes to the DNS server the VPN gave you. Often that is true. But it is not guaranteed, and the reason is simple: a VPN can only offer DNS servers. It does not own the part of your system that decides which server to ask. That job belongs to the resolver on your machine, to the network manager feeding it, and in some cases to the application you are using.
So, can a Linux DNS resolver override the nameservers provided by a VPN? Yes. It can ignore them, rank them lower than another server, send only some names to them, or replace them the next time the network changes. This article explains who makes that decision, how to check what is happening on your own machine, and what the usual fixes look like. It is a diagnostic guide, not a promise that any particular setup will behave a certain way, so we focus on commands you can run and results you can read.
Who actually decides which DNS server is used
On Linux there is no single "DNS setting". Several layers cooperate, and each can overrule the one above it.
- The application. A program usually calls the C library, which reads
/etc/nsswitch.confand/etc/resolv.conf. Some applications, including browsers, can skip this and speak DNS directly, for example over HTTPS. - The stub resolver. On many desktop distributions
/etc/resolv.confpoints to a local address such as127.0.0.53. That is a small listener run by systemd-resolved, which then forwards the question to a real server. Other systems use dnsmasq or another local cache in the same role. - The network manager. NetworkManager, systemd-networkd or a similar tool decides which DNS servers belong to which connection and passes them to the resolver. It can also write
/etc/resolv.confitself. - The VPN client or configuration. It may hand a DNS server to the network manager or resolver, or it may do nothing about DNS at all. Whether it does depends on how the client or configuration was built, so check on your machine instead of assuming.
- DHCP. The router that gave you an address also suggests DNS servers. Each time the lease renews or the Wi-Fi reconnects, that suggestion can arrive again.
The key idea is that the VPN's DNS server is one input among several. The resolver combines them using rules, and those rules are what you need to understand.

How systemd-resolved chooses between servers
On systems that use systemd-resolved, each network interface (called a link) can have its own DNS servers and its own settings. When a program asks for a name, the resolver does not simply ask every server. It picks links by two ideas.
Routing domains. A link can be marked as the right place to ask about certain domains, written with a leading tilde, such as ~corp.example. A name that matches goes to that link. A special routing domain ~. means "this link is a good place to ask about everything".
The default route flag. Each link also has a "Default Route" flag. If a link has it set to yes, it is eligible to receive questions that match no routing domain. If the physical link (for example your Wi-Fi) has this set to yes and the VPN link has it set to no, ordinary lookups still go out through Wi-Fi even though the tunnel is up.
This is the most common way a resolver overrides VPN nameservers on a modern desktop. The VPN's servers are present in the configuration, they appear in the output of resolvectl status, and they are simply not chosen for most names.
If you have read about split DNS, this will sound familiar. Split DNS is exactly the intended use of routing domains: only names under a work domain go to the VPN's server. The surprise happens when you wanted all names to go there and the setup is only doing the split version.
Step 1: look at what the resolver believes
Connect the VPN first, then run these commands in a terminal.
- Run
resolvectl status. For each link you see the DNS servers, any routing domains and the Default Route line. Note which link the VPN uses (often something liketun0,wg0orppp0) and which one is your physical link. - Run
resolvectl query example.com. At the end the output says which link answered. If it names your Wi-Fi or Ethernet link, the VPN's DNS was not used for that name. - Run
cat /etc/resolv.conf. If you seenameserver 127.0.0.53, systemd-resolved is the front door. If you see a private address such as192.168.1.1, programs are talking to the router directly, and the stub is not involved. - Run
ls -l /etc/resolv.conf. If it is a symbolic link, note where it points. A link to a file under/run/systemd/resolve/tells you systemd-resolved owns it. A link into/run/NetworkManager/tells you NetworkManager does.
Write down what you see. These four results answer most questions about who is in charge before you touch any setting.
Step 2: confirm on the wire
The tools above show configuration. To see what actually leaves your machine, watch port 53 while you load a page.
- Open one terminal and run
sudo tcpdump -ni any port 53. - In a browser or another terminal, visit a site you have not opened recently, or run
getent hosts some-new-name.example. - Watch the interface column. Lines mentioning your Wi-Fi interface and the router's address mean the question left through the local network. Lines on the VPN interface mean it went through the tunnel.
If you see nothing on port 53 at all while the page loads, the application may be using DNS over HTTPS. That traffic looks like ordinary web traffic on port 443, so it will not show up here. Check the browser's secure DNS setting, which is covered in the limits section below.
Common ways the resolver overrides VPN nameservers
Here are the situations that show up most often, with how to recognise each one.
| Situation | What you will see | Likely cause |
|---|---|---|
| VPN DNS listed but not used | resolvectl status shows the VPN link with servers, but resolvectl query is answered by the Wi-Fi link |
Physical link has Default Route set to yes and the VPN link has no ~. routing domain |
| Only work names resolve through the VPN | Names under one domain work, everything else uses the router | Split DNS: the VPN link only has specific routing domains |
| Edits to /etc/resolv.conf vanish | File content returns to its old state after a reconnect | File is generated by systemd-resolved, NetworkManager or a DHCP client |
| DNS changes after the Wi-Fi reconnects | Correct at first, wrong after sleep or a roaming event | DHCP or the network manager re-applied the router's DNS and did not restore the VPN's |
| Browser results differ from terminal | getent and resolvectl look right, the browser still behaves like the old network |
Browser uses its own secure DNS server |
| No VPN DNS at all | VPN link has no DNS servers listed | The client or configuration did not provide any, or the network manager did not apply them |
Use the table as a map, not as a diagnosis. Two causes can be present at once, for example split DNS plus a browser with its own resolver.
Step 3: make the VPN's DNS take priority
The right fix depends on what you found. These are the usual adjustments. Change one thing, then re-run Step 1 and Step 2 to see whether it made a difference.
With systemd-resolved
If the VPN link has DNS servers but is not the default route, you can ask the resolver to treat it as the place for all names. For a link named wg0, that looks like this.
- Run
sudo resolvectl dns wg0 SERVER_ADDRESSif the link has no server yet, using the address your VPN supplier gave you. If the link already lists a server, skip this. - Run
sudo resolvectl domain wg0 "~."so the VPN link accepts every name. - Run
sudo resolvectl default-route wg0 yes. - Run
resolvectl statusagain andresolvectl query example.comto confirm the VPN link answers.
These settings are held in memory and may disappear when the link goes down. To keep them, put the equivalent options in the connection profile, covered next.
With NetworkManager
NetworkManager keeps DNS settings inside each connection profile. In the graphical settings, open the VPN connection, go to the IPv4 or IPv6 tab, and look for the DNS fields and a checkbox such as "Use this connection only for resources on its network". If that box is ticked, the VPN is not the default route for names, which gives you the split behaviour. Unticking it makes the VPN the preferred place for all lookups. On the command line the related settings are ipv4.dns, ipv4.dns-priority and ipv4.never-default, and you can read them with nmcli connection show "PROFILE_NAME".
For a deeper walk-through of the network manager side, see the article on using a VPN with NetworkManager on Linux.
With a plain resolv.conf
If your system does not use a stub resolver and nothing regenerates the file, programs read /etc/resolv.conf directly. The first nameserver line is asked first. If it still points to the router, the VPN's server is only used as a fallback. In that case the cleanest fix is to configure the connection that writes the file, not to edit the file itself. A manual edit is fine for a quick test, but expect it to be overwritten.
Step 4: stop the overrides from coming back
A setup that works for ten minutes and then reverts is usually a symptom of one of these.
- Reconnects and sleep. When Wi-Fi drops and returns, DHCP sends the router's DNS again. Check
resolvectl statusafter waking the machine. If the VPN link lost its settings, the VPN client or connection profile is not reapplying them. - Competing tools. Running NetworkManager together with a script that edits
/etc/resolv.confleads to each overwriting the other. Pick one owner for that file. - Container and VM resolvers. Docker, Podman and virtual machines carry their own resolver settings. A container may keep asking the old server even when the host is correct.
- A second VPN or tunnel. If another tunnel or a mesh tool is active, its DNS settings can take over the default route flag.
For problems that look like a leak rather than a priority issue, the article on testing and fixing DNS leaks on Linux walks through the packet-level checks in more detail.

A plain example
Imagine a laptop on a cafe's Wi-Fi. The router hands out its own address as the DNS server. You connect to a VPN. resolvectl status shows two links. The Wi-Fi link has the router as its server and Default Route set to yes. The VPN link has a server of its own, but Default Route is no and it has no routing domain.
You run resolvectl query example.com, and it says the answer came from the Wi-Fi link. Nothing is broken in the tunnel. Your web traffic really does travel through it. But your DNS questions, which say which sites you are visiting, still go to the cafe's router.
You make the VPN link the default route, add the ~. routing domain, and query again. This time the VPN link answers. You then watch port 53 with tcpdump while loading a page and see the questions on the VPN interface. A reconnect later, you check again and find the setting survived because you saved it in the connection profile.
That sequence, observe, change one thing, observe again, is the whole method.
Limits and what to watch for
- No setting is a guarantee. Even when the VPN link answers your DNS questions, that only moves who sees them. It does not make you anonymous, and a VPN does not protect you from everything. For the broader picture, see how DNS itself works in the article on how DNS works.
- Browsers can go their own way. A browser with DNS over HTTPS enabled may ask a configured server directly. Look in the browser's privacy or security settings for a secure DNS option and see whether it is set to a custom provider.
- IPv6 is its own path. If the network hands out an IPv6 DNS server and the VPN only covers IPv4, questions can leave over IPv6.
resolvectl statuslists these servers too. - Corporate and school networks may require their DNS. Some networks run their own DNS for internal names. Replacing it can break access to those names. Only change what you are entitled to manage on that machine.
- Distribution differences. Defaults vary between distributions and versions, so command output and menu wording will differ. Treat the commands here as a starting point and confirm with your distribution's documentation.
- Do not edit blindly. Write down the original values before you change them, so you can go back.
Using this with your own VPN
VPNclient, the app that goes with an XPASS pass, is available for 64-bit Intel and AMD Linux desktops with systemd. The setup steps are in the help guide on setting up a VPN on Linux. Whether any particular VPN client changes DNS settings on your system is something to verify rather than assume, so after you connect, run the checks in Step 1 and Step 2 on your own machine and read the results. If the answers surprise you, the changes above are the place to start. If you are unsure, the support contact on your My Pass page is the right route for questions about the app itself.
Summary
A Linux DNS resolver can override the nameservers a VPN provides, because the VPN only offers servers and the resolver, the network manager, DHCP and the application decide which ones are used. Check with resolvectl status, resolvectl query and a short tcpdump capture before you change anything, then adjust the default route and routing domains or the connection profile, and test again after a reconnect. If you are comparing options for a Linux machine, the pricing page explains how XPASS prepaid passes work.
Frequently asked questions
Can a Linux resolver really ignore the DNS servers a VPN provides?
Yes. A VPN can only offer DNS servers. Which ones your programs actually use is decided by the resolver on your machine, the network manager that feeds it, and sometimes the application itself. If any of them is configured to prefer another server, the VPN's suggestion is not used.
How do I see which DNS server is really answering?
On systems with systemd-resolved, run resolvectl status to see the servers per interface and resolvectl query example.com to see which link answered. To confirm on the wire, run sudo tcpdump -ni any port 53 while you open a website.
Why does my /etc/resolv.conf keep changing back after I edit it?
On most modern distributions that file is generated by systemd-resolved, NetworkManager or a DHCP client. Your edit is replaced the next time the network changes. Set the DNS on the connection or interface instead of editing the file.
Does a browser use the Linux resolver?
Not always. Some browsers can use DNS over HTTPS and ask a configured server directly, which bypasses the system resolver and any DNS servers a VPN provided. Check the browser's secure DNS setting if results differ from the terminal.
Is it a problem if the VPN's DNS is not used?
It depends on your goal. For privacy, it means your DNS questions may still go to the local network or provider. For reaching names that only exist on a work network, it means those names may not resolve. Test first, then decide what to change.
References
About the author

Bob Kanokphon Thongdee
- Founder of XPASS VPN
- Co-founder of eSIMonline.asia
- More than 7 years in online marketing
- Founder of Cojourney Visa and Cojourney Travel
Need a VPN for a short trip or a busy month?
XPASS sells prepaid passes for a set number of days. You pay once and nothing renews automatically.
See passesKeep reading

Device Guides
How to Test and Fix DNS Leaks on Linux
Linux has several layers that decide where DNS questions go. Learn to test which one is answering while your VPN is up, and how to fix it on systemd-resolved, NetworkManager and plain resolv.conf.
9 min read

VPN Security
Split DNS with VPNs: What It Means
Split DNS lets a device ask one resolver about private names and another about everything else. Here is how it works, where it helps, and how to check it.
9 min read

Device Guides
How to Add a VPN in Linux NetworkManager
How NetworkManager stores VPN profiles, how to add one in GNOME, KDE or nmcli, and which settings (routes, DNS, auto-connect, secrets) decide whether it behaves well.
10 min read