Difference between revisions of "Resolv.conf"

From ArchWiki
Jump to: navigation, search
m (Regenerate /etc/resolv.conf: added link to openresolv package)
(21 intermediate revisions by 13 users not shown)
Line 1: Line 1:
[[Category:Networking (English)]]
+
[[Category:Domain Name System]]
{{i18n|Resolv.conf}}
+
[[es:Resolv.conf]]
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.
+
[[de:Resolv.conf]]
 +
[[fr:Resolv.conf]]
 +
[[it:Resolv.conf]]
 +
[[ja:Resolv.conf]]
 +
[[zh-CN:Resolv.conf]]
 +
From from the [http://www.kernel.org/doc/man-pages/online/pages/man5/resolv.conf.5.html 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.
+
:''"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==
+
== Preserve DNS settings ==
  
Dhcpcd, NetworkManager, and various other processes can overwrite {{Filename|/etc/resolv.conf}}. This is usually desirable behavior, but sometimes DNS settings need to be set manually (e.g. when using a static IP). There are several ways to accomplish this. If you are using NetworkManager, see [http://bbs.archlinux.org/viewtopic.php?id=45394 this thread] on how to prevent it from overriding your resolv.conf.
+
{{Pkg|dhcpcd}}, [[NetworkManager]], and various other processes can overwrite {{ic|/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 NetworkManager, see [https://bbs.archlinux.org/viewtopic.php?id=45394 this thread] on how to prevent it from overriding your {{ic|/etc/resolv.conf}}.
  
===Modify the dhcpcd Config===
+
=== Modify the dhcpcd Config ===
Dhcpcd's configuration file may be edited to prevent the dhcpcd daemon from overwriting {{Filename|/etc/resolv.conf}}. To do this, add the following to the last section of {{Filename|/etc/dhcpcd.conf}}:  
+
 
 +
dhcpcd's configuration file may be edited to prevent the dhcpcd daemon from overwriting {{ic|/etc/resolv.conf}}. To do this, add the following to the last section of {{ic|/etc/dhcpcd.conf}}:  
  
 
  nohook resolv.conf
 
  nohook resolv.conf
  
===Use resolv.conf.head===
+
{{Note|If you use [[netctl]] and static IP address assignment, do not use the {{ic|DNS*}} options in your profile, otherwise ''resolvconf'' is called and {{ic|/etc/resolv.conf}} overwritten.}}
Alternatively, you can create a file called {{Filename|/etc/resolv.conf.head}} containing your DNS servers. Dhcpcd will prepend this file to the beginning of resolv.conf. An example {{Filename|/etc/resolv.conf.head}} for someone using OpenDNS would be:
+
 
 +
=== Use resolv.conf.head ===
 +
 
 +
{{Expansion|When using {{Pkg|openresolv}}, this can be done also in {{ic|/etc/resolvconf.conf}} using the {{ic|name_servers}} and {{ic|name_servers_append}} options.}}
 +
 
 +
Alternatively, you can create a file called {{ic|/etc/resolv.conf.head}} containing your DNS servers. dhcpcd will prepend this file to the beginning of {{ic|/etc/resolv.conf}}. An example {{ic|/etc/resolv.conf.head}} for someone using [[OpenDNS]] would be:
  
 
  # OpenDNS servers
 
  # OpenDNS servers
Line 21: Line 33:
 
  nameserver 208.67.220.220
 
  nameserver 208.67.220.220
  
If you're not pleased with the OpenDNS servers you might the google nameservers as an alternative.
+
If you are not pleased with the OpenDNS servers, you might try [https://developers.google.com/speed/public-dns/ Google's nameservers] as an alternative.
  # google nameservers
+
 
 +
  # Google nameservers
 
  nameserver 8.8.8.8
 
  nameserver 8.8.8.8
 
  nameserver 8.8.4.4
 
  nameserver 8.8.4.4
  
===Write-protect resolv.conf===
+
=== Regenerate /etc/resolv.conf ===
Another way to protect your resolv.conf from being edited by anything is setting the write-protection attribute:
+
 
  chattr +i /etc/resolv.conf
+
Required package: {{Pkg|openresolv}}
 +
 
 +
resolvconf -u
 +
 
 +
=== Write-protect /etc/resolv.conf ===
 +
 
 +
Another way to protect your {{ic|/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 ===
  
===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 {{ic|/etc/resolv.conf.tail}} and add the following line:
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
 
  options timeout:1
  
 
Then restart your network daemon and see if it works better.
 
Then restart your network daemon and see if it works better.

Revision as of 21:30, 4 October 2013

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, 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 NetworkManager, see this thread on how to prevent it from overriding your /etc/resolv.conf.

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
Note: If you use netctl and static IP address assignment, do not use the DNS* options in your profile, otherwise resolvconf is called and /etc/resolv.conf overwritten.

Use resolv.conf.head

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: When using openresolv, this can be done also in /etc/resolvconf.conf using the name_servers and name_servers_append options. (Discuss in Talk:Resolv.conf#)

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.