

Find Out Which DNS Server Your Linux System Is Using In A Few Simple Steps: Quick Checks, resolv.conf, systemd-resolved, and NetworkManager
Find Out Which DNS Server Your Linux System Is Using In A Few Simple Steps. In this guide, you’ll learn how to identify the DNS server your Linux machine is currently using, regardless of whether you’re on Ubuntu, Debian, Fedora, Arch, or any other distro. We’ll walk through simple terminal commands, explain what the results mean, and show you how to switch DNS servers when needed. Expect a practical, no-nonsense approach with quick checks you can reuse anytime.
Introduction
Find out which dns server your linux system is using in a few simple steps.
If you’re curious about which DNS server your Linux box is actually querying, you’re in the right place. This article breaks down the steps to identify the active DNS servers across common Linux setups, including those that rely on /etc/resolv.conf, systemd-resolved, and NetworkManager. You’ll get easy-to-follow commands, quick interpretation tips, and a few best-practice notes so you can troubleshoot or optimize DNS as needed.
What you’ll find in this post
- Quick terminal checks you can run in under five minutes
- How to interpret results from resolv.conf, resolvectl, and nmcli
- Scenarios for different environments bare-metal Linux, desktops using NetworkManager, servers using systemd-resolved
- How to adjust DNS settings safely without breaking network connectivity
- Common pitfalls and troubleshooting steps
- A handy reference table of commands and expected outputs
- A concise FAQ with practical answers you can reuse
Useful URLs and Resources plain text
DNS basics – https://en.wikipedia.org/wiki/Domain_Name_System
RFC 1035 – https://www.ietf.org/rfc/rfc1035.txt
systemd-resolved – https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html
NetworkManager – https://wiki.gnome.org/Projects/NetworkManager
Ubuntu DNS setup – https://help.ubuntu.com/community/DNS
Arch Linux DNS – https://wiki.archlinux.org/title/Domain_name_resolution
DoT/DoH overview – https://www.cloudflare.com/learning-dns/what-is-dns/
DoT/DoH privacy and use cases – https://www.icann.org/resources/pages/privacy
DNS privacy and security – https://www.iana.org/domains/reserved
DNS performance tips – https://www.cloudflare.com/learning-d dns/dns-performance-speed/
Body
Overview: how Linux resolves DNS
DNS resolution on Linux is a layered process. Depending on your distribution and desktop/server setup, the system might:
- Use /etc/resolv.conf as the canonical source of DNS servers
- Rely on systemd-resolved to manage DNS for all interfaces
- Leverage NetworkManager to configure DNS for each active connection
- Use a direct, static list of DNS servers defined by a specific application or manual configuration
Because of these variations, the fastest way to identify the active DNS server is to check multiple places in a logical order. The steps below are designed to work regardless of which layer is handling DNS for you.
Section: Quick checks you can run in your terminal
Before you start, open a terminal. You’ll need sudo privileges for some commands, but many checks work without them.
- Check /etc/resolv.conf
- Command:
- cat /etc/resolv.conf
- grep -E ‘nameserver’ /etc/resolv.conf
- What you’re looking for:
- A line that starts with nameserver, followed by an IP address. You might see one or more lines.
- What it means:
- If resolv.conf exists and shows nameserver entries, that’s typically the DNS server the system is using. However, on systems that manage DNS dynamically, this file may be a symlink to another source like /run/systemd/resolve/stub-resolv.conf or /run/resolvconf/resolv.conf. In that case, the actual DNS servers are managed by the underlying service.
- Check for a symlink and the actual target
- ls -l /etc/resolv.conf
- readlink -f /etc/resolv.conf
- The target of the symlink. Common targets are:
- /run/systemd/resolve/stub-resolv.conf systemd-resolved
- /run/resolvconf/resolv.conf resolvconf
- If the file is a symlink to /run/systemd/resolve/stub-resolv.conf, systemd-resolved is involved. If it points to resolvconf, a resolvconf-based approach is in play. If it’s a plain file with nameserver lines, you’re likely dealing with a static or DHCP-provided configuration.
- If you suspect systemd-resolved is in charge
- resolvectl status
- systemd-resolve –status
- DNS servers listed under each network interface Link 2, Link 3, etc.. You’ll see lines like “DNS: 1.1.1.1 9.9.9.9” associated with a specific interface.
- You’re using systemd-resolved to manage DNS for those interfaces. The resolver’s status shows per-link DNS servers, which is handy if you have multiple NICs.
- If NetworkManager is handling DNS
- nmcli device show
| grep -i ‘IP4.DNS’ -n - nmcli dev show
| grep ‘IP4.DNS’ - One or more DNS server addresses shown for the active interface for example, IP4.DNS: 8.8.8.8, IP4.DNS: 1.1.1.1.
- NetworkManager is delivering DNS configuration to your interface. The output may show several interfaces. focus on the one you’re using e.g., eth0, enp3s0, wlp2s0.
- Use a comprehensive, one-shot check
- resolvectl status 2>/dev/null || systemd-resolve –status 2>/dev/null || nmcli dev show | grep -i ‘IP4.DNS’
- A consolidated view of which DNS servers are active on the system. If none appear, it might indicate a more complex setup or an intermittent DHCP assignment.
- If this returns DNS entries for an interface, that’s your DNS source. If nothing is returned, continue with the next sections to identify where DNS is being sourced.
- Quick interpretation cheat sheet table
Situation Command What you’ll see What it means /etc/resolv.conf lists nameservers cat /etc/resolv.conf lines starting with nameserver DNS servers defined here are used, unless overridden by a management service /etc/resolv.conf is a symlink to systemd-resolved ls -l /etc/resolv.conf. readlink -f /etc/resolv.conf target path like /run/systemd/resolve/stub-resolv.conf systemd-resolved handles DNS for the system systemd-resolved is active resolvectl status DNS for each Link shows IPs DNS managed by systemd-resolved NetworkManager manages DNS nmcli device show IP4.DNS lines show addresses DNS provided by NetworkManager for that interface All three show DNS? combination of above commands multiple DNS sources may be listed You’re in a mixed environment. confirm which one is in use for your active interface
Section: How to interpret the results
- Conflicting results: If /etc/resolv.conf shows DNS servers that don’t match what resolvectl or nmcli reports, you’re likely dealing with a layered setup where the service has final say. Generally, the last service started injects its DNS into the active chain.
- Multiple interfaces: Laptops often have Ethernet and Wi-Fi. DNS shown for one interface doesn’t automatically apply to the other. If you switch networks, you may see different DNS servers per interface.
- DHCP vs. static: If you’re on DHCP, the DHCP server on your network usually provides DNS servers. If you manually configured DNS, those will show up in the same outputs, potentially overriding DHCP values.
Section: How to change DNS servers safely
- Why you’d want to change DNS:
- Improve privacy, speed, or reliability
- Bypass ISP-level DNS filtering or restrictions
- Prefer DNS providers with DoT/DoH support or better filtering options
- Important note:
- On systems using systemd-resolved, editing /etc/resolv.conf directly is not the right long-term solution. use the proper interface to configure DNS.
- On NetworkManager-based systems, prefer the NM methods to ensure changes persist across reboots and reconnects.
- Safe, common methods by configuration source
A If systemd-resolved is active
- sudo resolvectl dns
1.1.1.1 8.8.8.8 - sudo systemd-resolve –flush-caches
- What it does:
- Sets per-interface DNS servers. Example: for interface eth0, you’d run: sudo resolvectl dns eth0 1.1.1.1 8.8.8.8.
- Flushes the resolver’s cache to ensure changes take effect immediately.
- Persistence:
- In many cases, you want to make a persistent change. This may involve editing your NetworkManager or distro-specific network configuration so that the DNS servers aren’t overwritten on reboot or reconnect.
B If NetworkManager handles DNS
- nmcli connection show
- nmcli connection modify
ipv4.dns “1.1.1.1 8.8.8.8” ipv4.dns-priority 100 - nmcli connection up
- Sets DNS servers for a specific connection. Make sure you replace
with your actual connection name. - Changes persist across reboots as long as the connection is managed by NetworkManager.
C If resolvconf manages DNS
- echo “nameserver 1.1.1.1” | sudo tee /etc/resolvconf/resolv.conf.d/head
- sudo resolvconf -u
- Inserts DNS servers into the head of the resolv.conf entries and rebuilds the resolv.conf.
- Works well on servers or desktops still using resolvconf.
D If you want a quick temporary test
- sudo bash -c ‘echo “nameserver 1.1.1.1” > /etc/resolv.conf’
- Temporarily overrides DNS. It will be overwritten by DHCP or a network manager on next network event.
Section: Practical tips for better DNS performance and privacy
- Prefer reputable DNS providers known for reliability and privacy, such as Cloudflare 1.1.1.1 or Google 8.8.8.8, if privacy policies align with your needs.
- Consider using DNS-over-TLS DoT or DNS-over-HTTPS DoH for encrypted DNS queries. DoT typically uses port 853. DoH uses port 443. DoT/DoH can be configured via some resolvers and clients that support it. not all Linux configurations expose it directly, but you can route DNS over TLS through resolvers like dnscrypt-proxy, or use DoH-capable resolvers.
- If you’re on a laptop, remember that network changes switching networks, VPNs, or mobile hotspots can trigger a DNS reconfiguration. Re-check after each network switch.
- For servers and containers, consider isolating DNS settings to avoid leakage between environments. A misconfigured DNS can accidentally expose internal domains to the outside.
Section: Do I need to worry about DNS caching?
- Yes, caching can affect how quickly you see DNS changes take effect. Some services cache aggressively:
- systemd-resolved caches DNS responses
- NetworkManager may cache DNS data per connection
- Browsers also cache DNS DNS over HTTPS can mitigate this in some cases
- If changes don’t appear to take effect:
- Flush caches systemd-resolved: sudo resolvectl flush-caches. browser caches manually
- Restart the network service sudo systemctl restart NetworkManager or sudo systemctl restart systemd-resolved
- Reconnect the network interface disable/enable the interface or reconnect to the Wi‑Fi
Section: Security considerations
- Be mindful of potential DNS spoofing or interception on untrusted networks. Using DoT or DoH can reduce exposure to man-in-the-middle DNS manipulation.
- Ensure you trust your DNS provider. Some enterprises route DNS through internal resolvers with access controls to protect internal domain names.
- Regularly check for updates to your DNS-related services systemd, NetworkManager, resolvconf to keep caches and features secure.
Section: Quick reference: commands by scenario
- Scenario A: You just want to see what DNS servers are in use
- nmcli device show
| grep IP4.DNS - Scenario B: You’re on a systemd-resolved setup
- resolvectl dns
1.1.1.1 8.8.8.8
- resolvectl dns
- Scenario C: You’re using NetworkManager for DNS
- Scenario D: You want to bypass dynamic DNS temporary
- echo “nameserver 1.1.1.1” | sudo tee /etc/resolv.conf
Frequently Asked Questions
What is DNS and why does my Linux system need it?
DNS translates human-friendly domain names into IP addresses that computers use to locate each other on the internet. Your Linux system needs DNS to access websites, services, and devices by name, not just by IP.
How do I know which DNS server my web browser uses?
Your browser typically uses the OS DNS settings or its own DoH/DoT configuration. On most Linux setups, the underlying system DNS as shown by /etc/resolv.conf, resolvectl, or nmcli determines what the browser uses unless you explicitly configure DoH in the browser.
Can I set a different DNS server for each network interface?
Yes. If you’re using NetworkManager or systemd-resolved, you can assign per-interface DNS servers. For example, you might use a private DNS on Ethernet and a public one on Wi‑Fi. Commands differ by service nmcli for NetworkManager, resolvectl for systemd-resolved.
What’s the difference between /etc/resolv.conf and resolv.conf
/resolv.conf is the file that lists DNS servers for the system. On many modern systems, this file is managed by a service systemd-resolved or resolvconf and may be a symlink to a dynamic source rather than a static file you edit directly.
How do I switch to a privacy-focused DNS provider?
Pick a provider that supports DoT/DoH if you want encrypted queries for example, Cloudflare or Quad9. Configure DNS accordingly via your preferred service systemd-resolved, NetworkManager, or resolvconf. Some users install a local resolver like dnscrypt-proxy to handle encryption. How to Check Server Ping Discord: Ping Test, Voice Latency, and Discord Latency Hacks
Why did my DNS change after I connected to a new network?
DHCP on the new network typically hands out DNS server addresses, or NetworkManager/systemd-resolved may reconfigure DNS automatically when a new interface or VPN connects. It’s normal for DNS to update when networks change.
How can I see DNS per network interface quickly?
Use resolvectl status to view per-link DNS for each interface, or use nmcli device show
Is there a risk in editing /etc/resolv.conf directly?
Yes, if your system uses systemd-resolved or NetworkManager, editing /etc/resolv.conf directly can be overwritten automatically. Use the appropriate management tool resolvectl, nmcli to set DNS persistently.
What should I do if DNS lookups fail after a change?
- Verify the DNS servers you configured are reachable ping the DNS IP.
- Flush DNS caches systemd-resolved and browser caches.
- Reconnect the network or restart the network service.
- Check for VPNs or proxies that might override DNS settings.
How can I test DNS speed and reliability?
You can run quick tests like:
- dig @
example.com to see response times from a specific DNS server - time dig @1.1.1.1 example.com to measure latency
- Compare results across a few providers 1.1.1.1, 8.8.8.8, 9.9.9.9 from your location
- For more comprehensive tests, use tools like mtr or traceroute to see where delays originate
Conclusion
Note: This section intentionally left blank. No separate conclusion per your requirements. Is Your Device Or DNS Server Not Responding Heres How To Troubleshoot It
Sources:
安卓翻墙终极指南:2025年最佳vpn推荐与使用教程,稳定连接、隐私保护、跨平台使用
2025年最佳steam vpn推荐:畅玩全球游戏,告别区域限制与提升隐私安全、降低延迟、解锁跨区域内容的全面指南
Nordvpn vs surfshark comparison: an in-depth 2025 guide to speed, security, pricing, and features
Microsoft edge vpn cloudflare Bring Your Bot to Life a Simple Guide to Inviting Your Bot to Your Discord Server