Error Codes Wiki

Linux DNS Troubleshooting — systemd-resolved, /etc/resolv.conf, and DNS Debugging

Warningnetwork

Overview

Fix Linux DNS resolution issues including systemd-resolved conflicts, /etc/resolv.conf management, DNS-over-HTTPS setup, and debugging DNS with dig and nslookup.

Key Details

  • Modern Linux uses systemd-resolved for DNS management — /etc/resolv.conf is often a symlink
  • Multiple DNS resolution paths can conflict: systemd-resolved, NetworkManager, manual /etc/resolv.conf
  • systemd-resolved listens on 127.0.0.53 which can confuse applications expecting a real DNS server
  • dig and nslookup bypass systemd-resolved and query DNS servers directly
  • resolvectl (or systemd-resolve) shows the current DNS configuration per network interface

Common Causes

  • /etc/resolv.conf overwritten by NetworkManager, VPN, or DHCP client
  • systemd-resolved not running or misconfigured
  • VPN client replacing DNS settings, breaking resolution after disconnection
  • Multiple DNS management systems conflicting (resolved + NetworkManager + manual)
  • DNS server unreachable or returning SERVFAIL for specific domains

Steps

  1. 1Check current DNS: resolvectl status to see DNS servers per interface
  2. 2Test resolution: dig example.com (uses system DNS) and dig @8.8.8.8 example.com (bypass local)
  3. 3Check resolv.conf: ls -la /etc/resolv.conf to see if it is a symlink and where it points
  4. 4Set DNS manually: resolvectl dns eth0 8.8.8.8 1.1.1.1 for systemd-resolved
  5. 5Fix for containers/Docker: add DNS=8.8.8.8 to /etc/systemd/resolved.conf and restart systemd-resolved
  6. 6Flush DNS cache: resolvectl flush-caches

Tags

dnsresolv-confsystemd-resolveddigname-resolution

Related Items

More in Network

Frequently Asked Questions

Multiple services manage it: systemd-resolved, NetworkManager, and DHCP clients. Check which manages it with ls -la /etc/resolv.conf. Use the managing service's configuration instead of editing resolv.conf directly.