Resolv.conf

The file is Article description::used to configure hostname resolution. It may be manually configured by the system administrator, or may be automatically populated by various network configuration and management tools. It is commonly used to manage DNS requests on Linux systems.

Available software
Many tools exist to help manage the file (or symlink).

DHCPCD
By default, dhcpcd overwrites with the suggested configuration of the connected network. This behavior can be completely disabled by modifying :

Alternatively, one may edit or, which will be appended to the start or end of , respectively.

OpenRC
When using NetworkManager on an OpenRC profile, should be a symlink pointing at. This will likely not result in an automatically managed file for the system, unless the   USE flag has been enabled for.

For information on using different DNS plugins with NetworkManager see the dns and rc-manager parts under MAIN SECTION of.

systemd
When using a systemd profile, is a natural choice to be used as a DNS resolver for NetworkManager. It is enabled by starting the service and creating a symlink (see below).

If migrating from a different profile, the file should be removed, then a symlink created to the systemd resolver:

openresolv
The package integrates with several other packages to dynamically update  when network configuration changes occur. When using openresolv, should be a regular file.

systemd-resolved
There are multiple options for setting up a symlink to work with systemd-resolved.

Two main features are supported:


 * Stub resolver: the nameserver is pointed at systemd-resolved, listening on 127.0.0.53. DNS queries are executed by systemd-resolved.
 * Search path: The "search" directive is used to configure default domain names to be used when resolving single-word DNS queries.

The available features depend on which target is used for the symlink.

resolv.conf file syntax
The syntax of is relatively straight-forward. Each line specifies an option: most commonly,  , or. Not every line is necessary; it is entirely possible to have a blank file, while maintaining a working system.

nameserver
The nameserver option takes the IP address that the resolver should query, either in IPv4 or IPv6 form. Multiple nameserver lines may be specified, but each line must have only one IP address. A maximum of three lines should be present in total. If more than one IP address is present, the resolver queries them in the order listed. If no nameserver entries are present, it will default to 127.0.0.1.

search
The search option accepts up to six domains, separated by tabs or spaces. This is used if the resolver receives a request without any dots in it. It will then try to resolve the query with the search domain appended, then the original request. For example, if the search domain was example.com, and you requested http://test/index.html, it would first query http://test.example.com/index.html , and then http://test/index.html.

domain
The domain directive is an obsolete name for the search directive that handles one search list entry only. For more syntax options, check.

Control of /etc/resolve.conf
To determine which network management utility is controlling the /etc/resolve.conf file, two methods exist:

head
Typically, the network management utility will write a comment at the top of the file specifying the name of the managing program. This can be checked using :

symlink target
will either be a regular file or a symlink to another file. When a symlink, it is easy to reveal what network management tool is controlling the file by looking at the printed path to the target:

External resources

 * https://zwischenzugs.com/2018/06/08/anatomy-of-a-linux-dns-lookup-part-i/ - An excellent blog series that describes how DNS works on Linux systems.
 * https://wiki.archlinux.org/index.php/Resolv.conf
 * https://forums.gentoo.org/viewtopic-t-1118492.html