/etc/resolv.conf: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
 
(24 intermediate revisions by the same user not shown)
Line 5: Line 5:
=Internal=
=Internal=


* [[]]
* [[Bind_Operations_-_Set_Up_DNS_Client#.2Fetc.2Fresolv.conf|Setup a DNS client]]
* [[Linux_7_Configuring_a_Network_Interface#PEERDNS|PEERDNS]]
* [[/etc/nsswitch.conf|/etc/nsswitch.conf]]


=Overview=
=Overview=


<tt>/etc/resolv.conf</tt> is the name of the file that configures the DNS resolver. The ''DNS resolver'' is a set of routines in the C library that provide access to DNS. Among other things, {{/etc/resolv.conf}} configures the [default search domains|resolv.conf#DefaulSearchDomains] and the [nameserver|resolv.conf#Nameservers] IP addresses.
<tt>/etc/resolv.conf</tt> is the name of the file that configures the DNS resolver. The ''DNS resolver'' is a set of routines in the C library that provide access to DNS. Among other things, <tt>/etc/resolv.conf</tt> configures the [[#DefaulSearchDomains|default search domains]] and the [[#Nameservers|nameserver]] IP addresses.


=Who Writes It?=


!!!Who Writes It?
Network configuration scripts like /usr/sbin/dhclient-script or [[NetworkManager]] write <tt>/etc/resolv.conf</tt> when configured to do so (see [[Linux_7_Configuring_a_Network_Interface#PEERDNS|PEERDNS]]=yes).


If PEERDNS is set to "no", you will need to edit it manually.


Network configuration scripts or [Network Manager] write /etc/resolv.conf when configured to do so (see PEERDNS=yes), or not, in which case you will need to edit it manually.
=Configure DNS via /etc/sysconfig/network-scripts=


The following settings should be specified in /etc/sysconfig/network-scripts/ifcfg-ethX:


!!!Configure DNS via /etc/sysconfig/network-scripts
To configure the DNS resolver with a specific DNS server and '''NOT''' the DNS server that comes with DHCP configuration, set:


The following settings should be specified in {{/etc/sysconfig/network-scripts/ifcfg-ethX}}:
<pre>
 
NM_CONTROLLED=no
To configure the DNS resolver with a specific DNS server and __NOT__ the DNS server that comes with DHCP configuration, set:
 
{{{
PEERDNS=no
PEERDNS=no
IPV6_PEERDNS=no
IPV6_PEERDNS=no
}}}
</pre>


Note that setting only one is not sufficient, both need to be set.
Note that setting only one is not sufficient, both need to be set.


Then specify the DNS IP address with  
Then specify the DNS IP address with:
 
{{{
DNS1=...
DNS2=...
}}}
 
<font color=red>The network configuration scripts will write this into /etc/resolv.conf.


Actually, if I set PEERDNS=no, nothing is written, I need to write it manually. Return to this.</font>
<pre>
DNS1="8.8.8.8"
DNS2="8.8.4.4"
</pre>


Also see [NM_CONTROLLED|LinuxNetwork#DisablingNetworkManager].
<font color=red>The network configuration scripts will write this into /etc/resolv.conf. Actually, if I set PEERDNS=no, nothing is written, I need to write it manually. Return to this.</font>


Also see [[NetworkManager_Operations#Disable_the_Network_Manager|Disable the NetworkManager - NM_CONTROLLED]].


!!OpenShift Example
<span id="Manual_resolv.conf_Configuration"></span>Alternatively, NetworkManager can be configured to NOT touch /etc/resolv.conf. The configuration is described here: {{Internal|NetworkManager_Configuration#.2Fetc.2Fresolv.conf_Processing_Mode|Configuring NetworkManager not to modify /etc/resolv.conf}}


All (/etc/sysconfig/network-scripts/ifcfg-eth0, /etc/sysconfig/network-scripts/ifcfg-eth1):
In both cases, /etc/resolv.conf must be manually updated as follows:


{{{
<pre>
...
# DNS resolver
IPV6_PEERDNS=no
PEERDNS=no
NM_CONTROLLED=no
DNS1=172.20.2.10
}}}
 
/etc/resolv.conf
 
{{{
# Manual 09/21/15
# Manual 09/21/15
domain openshift.local
domain openshift.local
search openshift.local
search openshift.local
nameserver 172.20.2.10
nameserver 172.20.2.10
}}}
</pre>


!!!Content
=Content=


{{/etc/resolv.conf}} contains
<tt>/etc/resolv.conf</tt> contains:


!!Nameservers
==Nameservers==


The {{nameserver}} is the DNS server IPv4 or IPv6 address.  
The <tt>nameserver</tt> is the DNS server IPv4 or IPv6 address.  


Up to {{MAXNS}} (currently 3, specified in {{resolv.h}}) name servers may be listed, one per keyword.
Up to <tt>MAXNS</tt> (currently 3, specified in <tt>resolv.h</tt>) name servers may be listed, one per keyword.


If multiple servers are listed, they are queried in order.  
If multiple servers are listed, they are queried in order.  


If no {{name server}} is specified, the default is to use the name server on the local machine.
If no <tt>name server</tt> is specified, the default is to use the name server on the local machine.


Example:
Example:


{{{
<pre>
nameserver 206.13.28.12
nameserver 206.13.28.12
nameserver 206.13.28.13
nameserver 206.13.28.13
nameserver 206.13.28.14
nameserver 206.13.28.14
}}}
</pre>


!!Domain
==Domain==


The {{domain}} keyword specifies the local domain name.  
The <tt>domain</tt> keyword specifies the local domain name.  


If no {{domain}} entry is present, the domain is determined from the local hostname returned by {{gethostname}} by taking everything after the first ".". If the hostname does not contain a domain part, the root domain is assumed.
If no <tt>domain</tt> entry is present, the domain is determined from the local hostname returned by <tt>gethostname</tt> by taking everything after the first ".". If the hostname does not contain a domain part, the root domain is assumed.


Example
Example:


{{{
<pre>
domain openshift.local
domain openshift.local
}}}
</pre>


==Search==


!!Search
<code>search</code> contains the search list of host name lookup. Its elements represent strings added to non-canonical host names when those non-canonical host names are resolved to IP addresses.  
 
The search list of host name lookup. Strings added to non-canonical host names when those non-canonical host names are resolved to IP addresses.  


The search list is normally determined from the local domain name, and by default it contains only the local domain name.
The search list is normally determined from the local domain name, and by default it contains only the local domain name.


This may be changed by listing the desired domain search path following the {{search}} keyword. It is used as follows: resolver queries having fewer than 1 dot will be attempted using each component of the search path in turn until a match is found.
This may be changed by listing the desired domain search path following the <code>search</code> keyword. It is used as follows: resolver queries having fewer than 1 dot will be attempted using each component of the search path in turn until a match is found.


 
<syntaxhighlight lang='text'>
{{{
search novaordis.com
search novaordis.com
}}}
</syntaxhighlight>
 
 
 
 
 
 
__Referenced by:__\\
[{INSERT com.ecyrd.jspwiki.plugin.ReferringPagesPlugin WHERE max=20, maxwidth=50}]

Latest revision as of 01:12, 22 November 2021

External

Internal

Overview

/etc/resolv.conf is the name of the file that configures the DNS resolver. The DNS resolver is a set of routines in the C library that provide access to DNS. Among other things, /etc/resolv.conf configures the default search domains and the nameserver IP addresses.

Who Writes It?

Network configuration scripts like /usr/sbin/dhclient-script or NetworkManager write /etc/resolv.conf when configured to do so (see PEERDNS=yes).

If PEERDNS is set to "no", you will need to edit it manually.

Configure DNS via /etc/sysconfig/network-scripts

The following settings should be specified in /etc/sysconfig/network-scripts/ifcfg-ethX:

To configure the DNS resolver with a specific DNS server and NOT the DNS server that comes with DHCP configuration, set:

NM_CONTROLLED=no
PEERDNS=no
IPV6_PEERDNS=no

Note that setting only one is not sufficient, both need to be set.

Then specify the DNS IP address with:

DNS1="8.8.8.8"
DNS2="8.8.4.4"

The network configuration scripts will write this into /etc/resolv.conf. Actually, if I set PEERDNS=no, nothing is written, I need to write it manually. Return to this.

Also see Disable the NetworkManager - NM_CONTROLLED.

Alternatively, NetworkManager can be configured to NOT touch /etc/resolv.conf. The configuration is described here:

Configuring NetworkManager not to modify /etc/resolv.conf

In both cases, /etc/resolv.conf must be manually updated as follows:

# Manual 09/21/15
domain openshift.local
search openshift.local
nameserver 172.20.2.10

Content

/etc/resolv.conf contains:

Nameservers

The nameserver is the DNS server IPv4 or IPv6 address.

Up to MAXNS (currently 3, specified in resolv.h) name servers may be listed, one per keyword.

If multiple servers are listed, they are queried in order.

If no name server is specified, the default is to use the name server on the local machine.

Example:

nameserver 206.13.28.12
nameserver 206.13.28.13
nameserver 206.13.28.14

Domain

The domain keyword specifies the local domain name.

If no domain entry is present, the domain is determined from the local hostname returned by gethostname by taking everything after the first ".". If the hostname does not contain a domain part, the root domain is assumed.

Example:

domain openshift.local

Search

search contains the search list of host name lookup. Its elements represent strings added to non-canonical host names when those non-canonical host names are resolved to IP addresses.

The search list is normally determined from the local domain name, and by default it contains only the local domain name.

This may be changed by listing the desired domain search path following the search keyword. It is used as follows: resolver queries having fewer than 1 dot will be attempted using each component of the search path in turn until a match is found.

search novaordis.com