Yes, you can discover the DNS server name in Linux with these simple steps. In this guide, you’ll learn easy, practical ways to see which DNS servers your system is using, how to read resolver configuration, and how to verify DNS resolution across various setups—whether you’re on systemd-resolved, NetworkManager, or classic /etc/resolv.conf. We’ll cover quick checks, per-interface details, and some troubleshooting tips so you can get reliable DNS results fast. Think of this as a friendly, no-fl fluff toolbox you can pull out whenever you need to confirm what your Linux box is using for DNS.
Useful URLs and Resources:
- resolv.conf explained – resolv.conf page on Linux docs
- systemd-resolved documentation – systemd-resolve and resolvectl man pages
- NetworkManager DNS info – NetworkManager docs
- RFC 1034 and RFC 1035 – DNS concepts and name resolution
- Wikipedia DNS – Domain Name System overview
Quick overview of what you’ll find here
- Why DNS info varies by setup systemd-resolved, NetworkManager, or classic resolv.conf
- Step-by-step commands to read current DNS servers
- How to verify DNS resolution and identify the active server
- How to handle containers, VMs, and DHCP-driven environments
- Practical tips to change or override DNS safely
Quick steps to discover the DNS server name in Linux
- Step 1: Check the resolver configuration file
- Step 2: Inspect the system’s resolver service systemd-resolved or resolvectl
- Step 3: Inspect DNS settings for network managers
- Step 4: Verify with a DNS query and confirm which server was used
- Step 5: Consider edge cases containers, virtualization, DHCP
The resolver file: /etc/resolv.conf
What to look for
- The file commonly contains lines starting with nameserver followed by an IP address.
- If you see multiple lines, you’re likely listing more than one DNS server, in order of preference.
- In newer setups using systemd, this file may be a symlink to a systemd stub resolver, such as /run/systemd/resolve/stub-resolv.conf.
How to inspect it
- Command: cat /etc/resolv.conf
- Command: grep -E ‘^nameserver’ /etc/resolv.conf
What this tells you:
- The IPs listed after each nameserver line are the DNS servers your system will query in order.
- If you see a line like: nameserver 127.0.0.53, you’re using the systemd-resolved stub resolver on the local loopback, and the real servers are managed elsewhere.
Common pitfall
- If /etc/resolv.conf is a symlink to /run/systemd/resolve/stub-resolv.conf or a similar path, the actual DNS servers are configured through systemd-resolved or NetworkManager rather than a static file. In that case, the resolver’s status commands below will give you the real server list.
Systemd-resolved: status, status, status
Why it matters
- systemd-resolved is a modern, centralized DNS resolver used by many Linux distros Ubuntu, Debian-based systems, Fedora variants, etc.. It aggregates DNS settings from various sources DHCP, VPNs, network managers and caches results.
How to check
- Command: systemd-resolve –status
- Alternative: resolvectl status on newer systemd versions
What you’ll see
- A summary of Link network interface blocks showing DNS servers per interface.
- Look for lines like:
- DNS Servers: 1.1.1.1 9.9.9.9
- DNS Domain: example.local
- If you’re using the classic loopback DNS 127.0.0.53, that means systemd-resolved is actively handling DNS, and the real servers are listed under the relevant link.
Quick commands and examples
- Basic status check:
- systemd-resolve –status
- If you prefer the shorter alias:
- resolvectl status
- What to extract:
- For each network interface, note the DNS Servers field.
Why this helps
- It gives you a centralized view across all adapters, VPNs, and Docker/VMs that piggyback on systemd-resolved.
- It also shows the local stub resolver’s presence, which is common in modern Linux setups.
NetworkManager: DNS and connections
Who uses NetworkManager
- Desktop-oriented distros Fedora Workstation, Ubuntu Desktop, etc. and many laptop configurations rely on NetworkManager to manage network connections and DNS.
How to inspect DNS with NetworkManager
- Command: nmcli device show
- This shows a lot of details, including DNS servers for each device IP4.DNS and IP6.DNS fields.
- More targeted:
- nmcli device show
| grep -E “IP4.DNS|IP6.DNS” - Example: nmcli device show wlp2s0 | grep IP4.DNS
- nmcli device show
- Quick summary:
- You’ll see DNS server addresses listed in the IP4.DNS entries; that’s what the device is using for DNS queries.
How to change DNS via NetworkManager safe and persistent
- Find your connection name:
- nmcli con show
- Set new DNS servers:
- nmcli con mod
ipv4.dns “1.1.1.1 8.8.8.8” - nmcli con mod
ipv4.dns-search “”
- nmcli con mod
- Apply changes:
- nmcli con up
–reload
- nmcli con up
- What to expect:
- After reloading, the DNS servers listed in resolvectl or systemd-resolved should reflect the new values, depending on your exact stack.
Why NetworkManager matters
- It’s the most common way laptops and desktop users configure DNS, thanks to user-friendly GUI tools and straightforward CLI commands.
Reading DNS per-interface details and direct lookups
Per-interface DNS details
- Command: nmcli device show | grep -E “IP4.DNS|IP6.DNS”
- This helps you map the DNS servers to a specific NIC eth0, wlan0, enp3s0, etc., which is particularly useful on multi-NIC systems or when you’re debugging VPN-related DNS leaks.
Quick test: validate DNS resolution
- Command: dig +short example.com
- Observations:
- The DNS server used is typically shown in the header of the resolution step, but you can also run:
- dig +trace example.com
- The first answer comes from the resolver currently in place; to see which server was used, check the SERVER line in the dig output the final answer will include something like SERVER: 127.0.0.53#53 for a local stub or the actual DNS server IP if directly queried.
Verify by querying a specific server
- Command: dig @1.1.1.1 example.com
- If this returns results, your system can reach that DNS server; if not, you might need to check connectivity or firewall rules.
Quick table: when to use which command
| Situation | Command | What it shows |
|---|---|---|
| See system-wide DNS servers systemd-resolved | systemd-resolve –status or resolvectl status | Lists per-link DNS servers |
| See DNS for all NetworkManager devices | nmcli device show | Shows IP4.DNS/IP6.DNS per device |
| See /etc/resolv.conf contents | cat /etc/resolv.conf | Static or stub-resolver content |
| Check per-interface DNS directly | nmcli device show |
IP4.DNS and IP6.DNS for a specific interface |
| Validate actual resolution and server used | dig example.com | Resolution results and server used |
Edge cases: containers, VMs, and DHCP
- Containers and Docker: When you run containers, DNS settings can be mounted from the host or overridden inside the container. Look at the container’s /etc/resolv.conf to see what DNS servers the container is using. If you’re using a modern container runtime, it usually forwards the host DNS settings unless you override them.
- Virtual machines: A VM may have its own NIC settings and DHCP-provided DNS, independent of the host. Inside the VM, repeat the same steps to identify its own DNS servers.
- DHCP-driven DNS: When a DHCP server provides DNS settings, your host might dynamically update /etc/resolv.conf or systemd-resolved. If you see frequent changes, it’s likely DHCP is pushing new DNS servers.
How to change DNS servers safely on Linux
- Systemd-resolved approach recommended on systems that use systemd
- Edit the resolved.conf file:
- sudo nano /etc/systemd/resolved.conf
- Add or modify the DNS= line, for example: DNS=1.1.1.1 8.8.8.8
- Restart the resolver:
- sudo systemctl restart systemd-resolved
- If you want /etc/resolv.conf to reflect the systemd-managed resolvers, you can set up the symlink:
- sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
- Edit the resolved.conf file:
- NetworkManager approach
- Identify your connection name and edit:
- nmcli con mod
ipv4.dns “1.1.1.1 8.8.8.8” - nmcli con mod
ipv4.dns-search “”
- nmcli con mod
- Bring the connection down and up to apply:
- nmcli connection down
- nmcli connection up
- nmcli connection down
- Identify your connection name and edit:
- Static /etc/resolv.conf approach less recommended on systems with active resolvers
- Create or edit /etc/resolv.conf and add lines like:
- nameserver 1.1.1.1
- nameserver 8.8.8.8
- Note: If a resolver service overwrites resolv.conf, changes may be overwritten on reboot or network change.
- Create or edit /etc/resolv.conf and add lines like:
Practical tips and best practices
- Avoid mixing configurations: If you use systemd-resolved, let it manage DNS and avoid editing /etc/resolv.conf directly unless you’re sure it won’t be overwritten.
- Prefer DNS servers you trust and monitor latency and privacy implications. Public DNS providers vary in performance and features like DNS over TLS.
- Test after changes: Always run a quick dig or nslookup to confirm that the intended DNS server is responding as expected.
- Be mindful of VPNs and corporate networks: VPNs often push their own DNS servers, which can override local settings. Check the DNS section of your VPN client or use resolvectl to see what’s active during a VPN session.
Real-world stats and context
- In recent years, many mainstream Linux distributions rely on systemd-resolved or NetworkManager to manage DNS. The result is that /etc/resolv.conf often points to a local stub 127.0.0.53 when systemd-resolved is active, with the actual servers configured elsewhere.
- NetworkManager remains the go-to DNS manager for desktop systems, providing an intuitive interface for changing DNS servers without editing files by hand.
- For servers, you’ll often see static DNS configuration or DHCP-driven DNS settings, especially in cloud environments and containers.
Quick reference: command cheat sheet
- View resolver configuration:
- cat /etc/resolv.conf
- grep -E ‘^nameserver’ /etc/resolv.conf
- Systemd-resolved status:
- systemd-resolve –status
- resolvectl status
- NetworkManager DNS:
- nmcli device show
- nmcli device show
| grep IP4.DNS
- Test DNS resolution:
- dig example.com
- dig @127.0.0.53 example.com
- dig @1.1.1.1 example.com
- Check link-specific DNS if using systemd-resolved:
- resolvectl status
- systemd-resolve –status
Frequently Asked Questions
How do I find my DNS server in Linux quickly?
The fastest way is to read /etc/resolv.conf for static configurations or to use systemd-resolve –status and nmcli device show to see per-interface DNS servers. If you’re on a systemd-based setup, you’ll likely see a local stub 127.0.0.53 in resolv.conf, with the real servers listed in systemd-resolved’s output.
What is /etc/resolv.conf used for?
resolv.conf is a resolver configuration file that specifies the DNS servers your system will query. It’s a central place for simple setups, but on modern systems, its contents can be managed by systemd-resolved or NetworkManager.
Why do I see 127.0.0.53 in /etc/resolv.conf?
That means your system uses systemd-resolved as the DNS resolver. The real DNS servers are configured elsewhere through systemd-resolved, NetworkManager, or DHCP. The local 127.0.0.53 is the stub resolver that forwards queries to the actual servers.
How can I change my DNS server in NetworkManager?
Use nmcli con mod
How do I verify which DNS server a system uses when I run a query?
Run dig example.com and look at the SERVER line or the header’s authoritative section. If you’re using a stub resolver, DIG will show SERVER: 127.0.0.53#53. If you query a specific server dig @1.1.1.1 example.com, you’ll see results only from that server.
Can DNS settings differ between interfaces?
Yes. With NetworkManager or per-interface configuration, different interfaces e.g., Ethernet vs. Wi-Fi can use different DNS servers. Check each interface with nmcli device show and inspect IP4.DNS values.
How do I know if DNS is being pushed by DHCP?
Check your interface’s DHCP client configuration or the router’s DHCP settings. If DNS values change automatically when you reconnect to Wi-Fi or reconnect to VPNs, DHCP or VPN DNS pushes are likely at play. systemd-resolved shows per-link DNS servers, which helps diagnose this.
What’s the difference between systemd-resolved and resolv.conf?
Systemd-resolved is a modern, centralized resolver that can aggregate DNS settings from multiple sources. resolv.conf is a traditional resolver configuration file. On systems using systemd-resolved, resolv.conf often points to a local stub resolver 127.0.0.53. The real servers are configured via systemd-resolved.
How can I test DNS performance quickly?
Run multiple dig queries to common domains e.g., google.com, cloudflare.com against different DNS servers you’re considering. Compare latency and consistency. Tools like “namebench” or “dnsperf” can help in more formal testing, though they’re more advanced. How to add member count to your discord server the ultimate guide: Real-Time Display, Widgets, Bots, and Easy Steps
How do I ensure DNS settings persist across reboots?
Use your distribution’s network manager to set DNS servers NetworkManager for desktops, netplan or NetworkManager on newer servers. For systemd-resolved, keep the DNS= entries in /etc/systemd/resolved.conf and restart the service. Avoid editing /etc/resolv.conf directly if a resolver service is managing it.
What should I do if DNS isn’t resolving after a change?
- Confirm the change actually took effect check resolv.conf, systemd-resolved status, and NetworkManager settings.
- Check for conflicting services e.g., DHCP or VPN clients overwriting DNS.
- Test with a known good DNS server like 8.8.8.8 or 1.1.1.1 to isolate network issues.
- Ensure you can reach the DNS server no firewall blocks, proper routing.
Is there a best practice for Linux DNS in mixed environments home, work, cloud?
Start with a stable local resolver systemd-resolved and a primary set of trusted DNS servers e.g., a secure public DNS provider. Add redundancy with a second server. Keep DHCP-derived DNS from overriding critical settings unless you rely on dynamic changes for VPNs or other networks. Periodically verify DNS health with quick tests and monitor latency.
How do I view DNS settings inside a Docker container?
Inside the container, inspect /etc/resolv.conf. By default, containers inherit host DNS settings unless you override them with –dns flags or custom Docker network configurations. For isolation, you can set specific DNS servers per container if needed.
Can I use DNS over TLS on Linux?
Yes, with additional tools and proxies like dnscrypt-proxy, Stubby, or Cloudflare’s 1.1.1.1 DNS over TLS support via resolvers. This is more advanced and may require careful configuration to work across all apps and containers.
What if I’m using a VPN and the DNS looks wrong?
VPNs often push their own DNS servers. Check your VPN settings and test DNS resolution both with and without the VPN connected. You may want to force a specific DNS server for certain apps or routes using firewall rules or per-app DNS configurations depending on your OS and VPN client capabilities. How to configure virtual machine in windows server 2012 a comprehensive guide: A practical Hyper-V VM setup
If you want a quick, repeatable workflow to always know which DNS server your Linux machine uses, start with /etc/resolv.conf for baseline visibility, then move to systemd-resolved or NetworkManager for authoritative, per-interface, and dynamic configurations. With these steps, you’ll never wonder which DNS server is serving your queries again. And when in doubt, a simple dig query and a quick check of resolvectl or nmcli will usually tell you everything you need.
Sources:
Nordvpn eero router setup 2026: The Ultimate Guide to VPN on Eero Routers
Vpnnext VPN 加密上网全面指南:隐私保护、速度优化、解锁地理限制与实际使用技巧
Geo edge vpn full guide for privacy, streaming, geo-restrictions, and setup tips Why your computer wont connect to the domain server: Quick Fixes for Domain Join, DNS, and Network Problems