If you're an Ubuntu user, you've probably experienced a situation where "you can access via IP but not via the domain name." In such cases, the root of the problem is often due to DNS settings. Particularly, recent versions of Ubuntu use the systemd-resolved
DNS resolver daemon by default, making it crucial to understand its architecture.
1. Flow of DNS Requests
Carefully read and understand the following summary, and most issues will be resolved.
- The user sends a request via an application like a browser to a domain.
- Linux, by default, reads
/etc/resolv.conf
to resolve DNS (this file is a symbolic link to/run/systemd/resolve/stub-resolv.conf
). /run/systemd/resolve/stub-resolv.conf
is set to127.0.0.53
, which is wheresystemd-resolved
comes into play.- The system's
systemd-resolved
is controlled by the configuration file/etc/systemd/resolved.conf
. - In other words,
systemd-resolved
queries the DNS servers set in/etc/systemd/resolved.conf
, - receiving a response and completing the domain to IP address conversion.
2. Summary of Key Components
As explained above, systemd-resolved
has four key configuration files. Understanding the role of these files is crucial.
2-1. /etc/resolv.conf
- Location for reading the DNS server list in traditional Linux systems
- However, it must currently exist as a symbolic link for compatibility with systemd.
- Normally, it should be configured like this to work correctly:
bash /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
- Thus, this file acts as a “mediator between traditional apps and systemd-resolved” in the current system.
2-2. /run/systemd/resolve/stub-resolv.conf
- Contains information about the local DNS stub server (127.0.0.53) managed by
systemd-resolved
. - If
/etc/resolv.conf
points to this file, all DNS requests will pass throughsystemd-resolved
.
2-3./etc/systemd/resolved.conf
- Essential configuration file for
systemd-resolved
. - Allows priority designation by setting items like
DNS=
andFallbackDNS=
. - Permanent settings that persist after reboot.
2-4. /run/systemd/resolve/resolv.conf
- A file that contains the actual DNS server list managed by
systemd-resolved
. - Advanced users can connect this file as
/etc/resolv.conf
instead ofstub-resolv.conf
to request directly to the DNS servers (bypass setting).
3. Example of Problems: Unstable DNS Servers Configured on ISP-Provided Routers
- The DNS server provided by a major ISP in South Korea, KT (e.g.,
168.126.63.1
), is set on the router, but intermittent DNS issues occur when I do not have control over that router. - KT's DNS often has unstable response times or fails the UDP/TCP handshake.
- If the
systemd-resolved
logs show repeated messages like the following, it is a sign of trouble:Using degraded feature set TCP instead of UDP for DNS server 168.126.63.1. Using degraded feature set UDP instead of TCP for DNS server 168.126.63.1.
- As a result, domain resolution fails → website access becomes unavailable.
4. Recommended DNS Servers
Name | Address | Features |
---|---|---|
Google DNS | 8.8.8.8 , 8.8.4.4 |
Fast and reliable |
Cloudflare DNS | 1.1.1.1 , 1.0.0.1 |
Fast speed and excellent privacy protection |
Quad9 | 9.9.9.9 |
Provides security threat filtering |
5. How to Set Up a Reliable DNS
- Open the
/etc/systemd/resolved.conf
file.
[Resolve]
DNS=1.1.1.1 8.8.8.8
FallbackDNS=9.9.9.9
- Apply the settings.
sudo systemctl restart systemd-resolved
- Check if
/etc/resolv.conf
is correctly linked.
ls -l /etc/resolv.conf
→ It should be linked to /run/systemd/resolve/stub-resolv.conf
.
If necessary, reset forcibly:
sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
6. Be Cautious of NetworkManager's Interference
In Ubuntu with a GUI environment, NetworkManager
can sometimes overwrite DNS settings.
- If automatic DNS settings are enabled, the
systemd-resolved
settings may be ignored. - Solution:
bash nm-connection-editor
→ Edit connection → IPv4 tab → Turn off automatic DNS → Enter manual DNS.
7. Conclusion
- It is advisable to avoid using KT's DNS due to frequent reports of instability.
- Configuring DNS through
systemd-resolved
is a very powerful method to enhance stability in Ubuntu. - By understanding and applying the settings correctly, you can reduce the stress of domain resolution failures.
8. Jesse's Comment
Settings based on understanding are the strongest security and maintenance. I hope this article provides practical help to those who were confused about DNS settings in Ubuntu.
Add a New Comment