configuration

resolv.conf — Resolver configuration

The glibc resolver reads /etc/resolv.conf for name server addresses, search domains and resolver options. ndots controls when a name is first tried as absolute; default is normally 1 in glibc. A search list can cause extra queries; fully qualified names with trailing dot avoid suffix search. Multiple name servers are generally tried according to resolver behavior, not a universal load balancing guarantee. This file may be a symlink or generated by systemd-resolved, NetworkManager, DHCP or another manager; edit the owning configuration rather than replacing the symlink. The last search directive supersedes earlier search lists in glibc. NSS order, application resolver and caches also matter. Inspect effective manager settings and getent results for authorized names; parsing a synthetic file does not validate DNS. Changes may be picked up by new resolver calls or cached; follow manager documentation. Restore previous owner-managed configuration and test resolution.

Formal Syntax & Structure

linux syntaxlinux
nameserver IP_ADDRESSsearch DOMAIN ...options ndots:N timeout:N attempts:N

Parameters & Attributes

NameTypeDescription
nameserverdirectiveDNS server address
searchdirectiveSearch domain list
optionsdirectiveResolver options such as ndots

Return Value

configuration or inspection

Resolver policy input, not a DNS response or reachability test.

Working Example

Example Snippetlinux
set -eud=$(mktemp -d)trap 'rm -rf -- "$d"' EXITprintf 'nameserver 192.0.2.53\nsearch lab.example\noptions ndots:2\n' > "$d/resolv.conf"awk '$1=="nameserver" || $1=="search" || $1=="options" {print}' "$d/resolv.conf"
Linux Reference