- Home
- Packages
- Forums
- Wiki
- Bugs
- AUR
- Download

# Resolv.conf

From ArchWiki

From from the resolv.conf(5) man page:

  "The resolver is a set of routines in the C library that provide access to the Internet Domain Name System (DNS). The resolver configuration file contains information that is read by the resolver routines the first time they are invoked by a process. The file is designed to be human readable and contains a list of keywords with values that provide various types of resolver information.

  "On a normally configured system this file should not be necessary. The only name server to be queried will be on the local machine; the domain name is determined from the host name and the domain search path is constructed from the domain name."

## Preserve DNS settings

dhcpcd, netctl, NetworkManager, and various other processes can overwrite `/etc/resolv.conf`. This is usually desirable behavior, but sometimes DNS settings need to be set manually (e.g. when using a static IP address). There are several ways to accomplish this.

- If you are using dhcpcd, see #Modify the dhcpcd config below.
- If you are using NetworkManager, see this thread on how to prevent it from overriding your `/etc/resolv.conf`.
- If you are using netctl and static IP address assignment, do not use the `DNS*` options in your profile, otherwise resolvconf is called and `/etc/resolv.conf` overwritten.

### Modify the dhcpcd config

dhcpcd's configuration file may be edited to prevent the dhcpcd daemon from overwriting `/etc/resolv.conf`. To do this, add the following to the last section of `/etc/dhcpcd.conf`:

    nohook resolv.conf

### Use resolv.conf.head

Alternatively, you can create a file called `/etc/resolv.conf.head` containing your DNS servers. dhcpcd will prepend this file to the beginning of `/etc/resolv.conf`. An example `/etc/resolv.conf.head` for someone using OpenDNS would be:

    # OpenDNS servers
    nameserver 208.67.222.222
    nameserver 208.67.220.220

If you are not pleased with the OpenDNS servers, you might try Google's nameservers as an alternative.

    # Google nameservers
    nameserver 8.8.8.8
    nameserver 8.8.4.4

### Regenerate /etc/resolv.conf

Required package: openresolv

    resolvconf -u

### Write-protect /etc/resolv.conf

Another way to protect your `/etc/resolv.conf` from being modified by anything is setting the write-protection attribute:

    # chattr +i /etc/resolv.conf

### Use timeout option to reduce hostname lookup time

If you are confronted with a very long hostname lookup (may it be in pacman or while browsing), it often helps to define a small timeout after which an alternative nameserver is used. To do so, create a file called `/etc/resolv.conf.tail` and add the following line:

    options timeout:1

Then restart your network daemon and see if it works better.

Retrieved from "https://wiki.archlinux.org/index.php?title=Resolv.conf&oldid=280377"
Category:

- Domain Name System

## Navigation menu