Linux DNS Resolution Failures — resolv.conf, systemd-resolved & nsswitch
About Linux DNS Resolution Failures
Fix Linux DNS resolution failures including 'Temporary failure in name resolution', systemd-resolved issues, resolv.conf overwriting, and nsswitch.conf misconfiguration. 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: /etc/resolv.conf specifies DNS servers — may be managed by systemd-resolved, NetworkManager, or resolvconf. systemd-resolved provides a local DNS stub at 127.0.0.53 — resolv.conf should point to this. /etc/nsswitch.conf controls name resolution order (files, dns, mdns, etc.). Docker containers use their own /etc/resolv.conf — 127.0.0.53 does not work inside containers. VPN software often modifies resolv.conf, breaking DNS when disconnected. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.
The most common reasons this occurs include: Empty or incorrect /etc/resolv.conf (no nameserver entries). systemd-resolved service not running. NetworkManager or DHCP client overwriting manual resolv.conf changes. Docker container unable to reach 127.0.0.53 (host-only stub resolver). VPN modified resolv.conf and did not restore it on disconnect. Identifying the root cause is the first step toward finding the right solution.
To resolve this, follow these recommended steps: Check current DNS: cat /etc/resolv.conf — should have nameserver entries. Test resolution: nslookup google.com or dig google.com. Restart systemd-resolved: sudo systemctl restart systemd-resolved. Set manual DNS: echo 'nameserver 8.8.8.8' | sudo tee /etc/resolv.conf. For persistent config: edit /etc/systemd/resolved.conf and set DNS=8.8.8.8 1.1.1.1, then restart resolved. 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 my resolv.conf keep getting overwritten?
NetworkManager, DHCP, or systemd-resolved manages it. For systemd-resolved: edit /etc/systemd/resolved.conf instead. For NM: set DNS in the connection profile.
Overview
Fix Linux DNS resolution failures including 'Temporary failure in name resolution', systemd-resolved issues, resolv.conf overwriting, and nsswitch.conf misconfiguration.
Key Details
- /etc/resolv.conf specifies DNS servers — may be managed by systemd-resolved, NetworkManager, or resolvconf
- systemd-resolved provides a local DNS stub at 127.0.0.53 — resolv.conf should point to this
- /etc/nsswitch.conf controls name resolution order (files, dns, mdns, etc.)
- Docker containers use their own /etc/resolv.conf — 127.0.0.53 does not work inside containers
- VPN software often modifies resolv.conf, breaking DNS when disconnected
Common Causes
- Empty or incorrect /etc/resolv.conf (no nameserver entries)
- systemd-resolved service not running
- NetworkManager or DHCP client overwriting manual resolv.conf changes
- Docker container unable to reach 127.0.0.53 (host-only stub resolver)
- VPN modified resolv.conf and did not restore it on disconnect
Steps
- 1Check current DNS: cat /etc/resolv.conf — should have nameserver entries
- 2Test resolution: nslookup google.com or dig google.com
- 3Restart systemd-resolved: sudo systemctl restart systemd-resolved
- 4Set manual DNS: echo 'nameserver 8.8.8.8' | sudo tee /etc/resolv.conf
- 5For persistent config: edit /etc/systemd/resolved.conf and set DNS=8.8.8.8 1.1.1.1, then restart resolved