Error Codes Wiki

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

Warningnetwork

About Linux DNS Troubleshooting

Fix Linux DNS resolution issues including systemd-resolved conflicts, /etc/resolv.conf management, DNS-over-HTTPS setup, and debugging DNS with dig and nslookup. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.

Here are the key things to understand: 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. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.

The most common reasons this occurs include: /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. Identifying the root cause is the first step toward finding the right solution.

To resolve this, follow these recommended steps: Check current DNS: resolvectl status to see DNS servers per interface. Test resolution: dig example.com (uses system DNS) and dig @8.8.8.8 example.com (bypass local). Check resolv.conf: ls -la /etc/resolv.conf to see if it is a symlink and where it points. Set DNS manually: resolvectl dns eth0 8.8.8.8 1.1.1.1 for systemd-resolved. Fix for containers/Docker: add DNS=8.8.8.8 to /etc/systemd/resolved.conf and restart systemd-resolved. Flush DNS cache: resolvectl flush-caches. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.

This article is part of our Linux Error Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.

Quick Answer

Why does /etc/resolv.conf keep getting overwritten?

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.

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.