https://wiki.archlinux.org/api.php?action=feedcontributions&user=Jeffcasavant&feedformat=atomArchWiki - User contributions [en]2024-03-28T20:10:49ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Domain_name_resolution&diff=284496Domain name resolution2013-11-25T03:52:02Z<p>Jeffcasavant: Added note that resolvconf.conf can be edited in order to make changes to future generated resolv.conf files.</p>
<hr />
<div>[[Category:Domain Name System]]<br />
[[es:Resolv.conf]]<br />
[[de:Resolv.conf]]<br />
[[fr:Resolv.conf]]<br />
[[it:Resolv.conf]]<br />
[[ja:Resolv.conf]]<br />
[[zh-CN:Resolv.conf]]<br />
From from the [http://www.kernel.org/doc/man-pages/online/pages/man5/resolv.conf.5.html resolv.conf(5)] man page:<br />
:''"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.''<br />
<br />
:''"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."''<br />
<br />
== Preserve DNS settings ==<br />
<br />
{{Pkg|dhcpcd}}, [[netctl]], [[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. <br />
*If you are using dhcpcd, see [[#Modify the dhcpcd config]] below.<br />
*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}}.<br />
*If you are using [[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.<br />
<br />
=== Modify resolvconf.conf ===<br />
<br />
You may modify resolvconf's configuration file. Entries from {{ic|/etc/resolvconf.conf}} will be propagated forwards into the generated {{ic|/etc/resolv.conf}}<br />
<br />
=== Modify the dhcpcd config ===<br />
<br />
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}}: <br />
<br />
nohook resolv.conf<br />
<br />
=== Use resolv.conf.head ===<br />
<br />
{{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.}}<br />
<br />
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:<br />
<br />
# OpenDNS servers<br />
nameserver 208.67.222.222<br />
nameserver 208.67.220.220<br />
<br />
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.<br />
<br />
# Google nameservers<br />
nameserver 8.8.8.8<br />
nameserver 8.8.4.4<br />
<br />
=== Regenerate /etc/resolv.conf ===<br />
<br />
Required package: {{Pkg|openresolv}}<br />
<br />
resolvconf -u<br />
<br />
=== Write-protect /etc/resolv.conf ===<br />
<br />
Another way to protect your {{ic|/etc/resolv.conf}} from being modified by anything is setting the write-protection attribute:<br />
<br />
# chattr +i /etc/resolv.conf<br />
<br />
=== Use timeout option to reduce hostname lookup time ===<br />
<br />
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:<br />
<br />
options timeout:1<br />
<br />
Then restart your network daemon and see if it works better.</div>Jeffcasavant