What Is /etc/resolv.conf
Content on WhatAnswers is provided "as is" for informational purposes. While we strive for accuracy, we make no guarantees. Content is AI-assisted and should not be used as professional advice.
Last updated: April 11, 2026
Key Facts
- Created in 1984 as part of Berkeley Software Distribution (BSD) for DNS resolution configuration
- Located at /etc/resolv.conf on Unix and Linux systems as a plain text file with world-readable permissions
- Typically contains 3-5 nameserver entries, with common public options being 8.8.8.8 (Google) and 1.1.1.1 (Cloudflare DNS)
- Supports directives like 'nameserver', 'search', 'domain', 'options', and 'sortlist' for customizing DNS query behavior
- Automatically overwritten by DHCP clients on 70%+ of systems; manual edits often don't persist across reboots unless using immutable flag
Overview
/etc/resolv.conf is a configuration file found on Unix and Linux systems that controls how the system resolves domain names to IP addresses. This plain text file serves as the central repository for DNS (Domain Name System) resolver settings, specifying which nameservers the system should query when translating human-readable domain names like example.com into their corresponding IP addresses. The file is typically world-readable with permissions of 644, allowing all users to view DNS configuration while restricting modifications to root.
First introduced in 1984 as part of the Berkeley Software Distribution (BSD), /etc/resolv.conf has remained a fundamental component of Unix-like operating systems for over four decades. Despite modern alternatives like systemd-resolved and NetworkManager emerging in recent years, this file continues to be the standard method for DNS configuration on the vast majority of Linux systems worldwide. Understanding this file is essential knowledge for system administrators, DevOps engineers, and advanced users who need to manage network connectivity, troubleshoot DNS issues, or implement custom DNS security policies.
How It Works
The /etc/resolv.conf file operates by providing the system's resolver library with a prioritized list of DNS servers to contact when resolving domain names. When an application needs to determine the IP address associated with a domain name, the system consults this file to determine which servers to query. The resolver attempts each nameserver in order until it receives a successful response or exhausts the list, using UDP port 53 by default for DNS queries.
- Nameserver Directive: The 'nameserver' entries specify the IP addresses of DNS servers the system should use for resolution. Typically, files contain 1-3 nameserver entries (though the system honors up to 3 by default), with common choices being Google's 8.8.8.8 or Cloudflare's 1.1.1.1. Each line beginning with 'nameserver' adds another server to the query list in priority order.
- Search Domain Directive: The 'search' line specifies a list of domain suffixes to append automatically when looking up short hostnames. For example, if 'search example.com corp.local' is configured and a user requests 'server', the system automatically searches for 'server.example.com' and 'server.corp.local' before trying 'server' alone, significantly improving usability in corporate environments.
- Domain Directive: The 'domain' setting defines a single domain name to append to queries, functioning similarly to search but accepting only one domain rather than a list. This directive is considered legacy and is less commonly used than search in modern configurations, though it remains supported for backward compatibility.
- Options and Advanced Directives: Advanced directives like 'options' allow fine-tuning resolver behavior with settings such as timeout values, retry counts, and IPv6 preference. The 'sortlist' directive enables users to specify preferred IP address ordering, while 'ndots' controls when domain search suffixes are appended automatically.
Key Comparisons
| Aspect | /etc/resolv.conf | systemd-resolved | NetworkManager |
|---|---|---|---|
| Configuration Method | Plain text file, manually edited or auto-generated | Systemd service with D-Bus API and unit files | GUI tool, CLI, or configuration files |
| Year Introduced | 1984 (BSD) | 2014 (systemd 217) | 2004 (Red Hat) |
| DNS Caching | No built-in caching; delegated to NSCD or other services | Integrated local DNS caching with 4MB default cache | Integrates with systemd-resolved for caching |
| Dynamic Updates | Often overwritten by DHCP clients at boot | Handles dynamic updates from DHCP, VPN, and interfaces automatically | Manages dynamic DNS updates through network profiles |
| Complexity | Simple and straightforward for basic setup | More complex but offers logging, caching, and DNSSEC support | Moderate with graphical configuration options |
Why It Matters
- Network Connectivity Foundation: Without proper /etc/resolv.conf configuration, systems cannot resolve domain names to IP addresses, making internet access impossible. This file is therefore critical to establishing and maintaining basic network connectivity on any Unix or Linux system, making it one of the first files to check during network troubleshooting.
- Security and Privacy Control: By specifying which DNS servers your system queries, /etc/resolv.conf directly impacts your privacy and security posture. Users can choose privacy-focused DNS providers like Cloudflare (1.1.1.1) or Quad9 (9.9.9.9) instead of relying on ISP nameservers that may log queries for analytics or advertisement purposes.
- Troubleshooting Network Issues: When DNS resolution fails, system administrators immediately check /etc/resolv.conf to verify nameserver configuration and search domains. Understanding this file is essential for diagnosing connectivity problems, implementing split-DNS configurations, and resolving host lookup failures in production environments.
- Legacy System Support: Many older systems, embedded devices, and containerized applications still rely directly on /etc/resolv.conf for DNS configuration. Knowledge of this file is necessary for supporting diverse computing environments, maintaining backward compatibility, and ensuring DNS functionality across heterogeneous infrastructure.
The /etc/resolv.conf file remains a cornerstone of DNS configuration in Linux and Unix systems despite being over four decades old. Its simplicity and universal availability make it an essential tool for network management, troubleshooting, and security optimization. Whether you're managing a single workstation or administering large server infrastructure, understanding /etc/resolv.conf is fundamental to effective system administration and network operations.
More What Is in Daily Life
Also in Daily Life
More "What Is" Questions
Trending on WhatAnswers
Browse by Topic
Browse by Question Type
Sources
- Linux man-pages: resolv.confGPL-2.0
- Wikipedia: resolv.confCC-BY-SA-3.0
- systemd-resolved Interface DocumentationLGPL-2.1+
Missing an answer?
Suggest a question and we'll generate an answer for it.