How many nameserver can be added to /etc/resolve.con

General support questions
Post Reply
itannu
Posts: 20
Joined: 2021/05/28 14:10:05

How many nameserver can be added to /etc/resolve.con

Post by itannu » 2021/09/23 14:13:19

Hi

Can anyone please tell me how many nameserver can be added to /etc/resolve.conf.
We actually have four so can four nameservers IP's added. ( I read somewhere only 3 can be added).

Another question is do i need to restart the network service after updating the nameservers.

Please let me know . Thank you

User avatar
TrevorH
Site Admin
Posts: 33191
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How many nameserver can be added to /etc/resolve.con

Post by TrevorH » 2021/09/23 14:19:17

man resolv.conf
nameserver Name server IP address
Internet address of a name server that the resolver should query, either an IPv4 address (in dot notation),
or an IPv6 address in colon (and possibly dot) notation as per RFC 2373. Up to MAXNS (currently 3, see
<resolv.h>) name servers may be listed, one per keyword. If there are multiple servers, the resolver li‐
brary queries them in the order listed.
Worth reading the rest of the info in there as it tells you a whole bunch of stuff that isn't immediately obvious or sometimes even expected.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

itannu
Posts: 20
Joined: 2021/05/28 14:10:05

Re: How many nameserver can be added to /etc/resolve.con

Post by itannu » 2021/09/23 15:20:55

Thank you.

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: How many nameserver can be added to /etc/resolve.con

Post by jlehtone » 2021/09/23 19:50:00

There is more. The glibc is not the only possible resolver. Particularly, if you do use NetworkManager.service (which is the default) rather than network.service.

man NetworkManager.conf describes option dns.

What I did was to install dnsmasq (sudo yum install dnsmasq) and create file:

Code: Select all

$ cat /etc/NetworkManager/conf.d/00-dns.conf 
[main]
dns=dnsmasq
Now, when NetworkManager.service starts, it does start an instance of 'dnsmasq' and updates file:

Code: Select all

$ cat /etc/resolv.conf
# Generated by NetworkManager
search example.com
nameserver 127.0.0.1
That means that programs on this host query the local dnsmasq for names. Where does it ask from? NetworkManager did give it (via DBus) names servers that the connections have (in local config or from DHCP). The dnsmasq will cache results (i.e. make less repeating queries), has different limit on name servers than glibc (more than 3), and overall makes queries differently. The other options, systemd-resolved and unbound, are probably as good as dnsmasq.

The default is that "NetworkManager will update /etc/resolv.conf to reflect the nameservers provided by currently active connections."
In other words, if you do use NM and did edit /etc/resolv.conf, NM will erase your changes.

If you do use network.service, then it too updates the /etc/resolv.conf with the DNS entries in config and/or the name servers dhclient gets from DHCP.

With four nameservers I would use dnsmasq even with network.service (but then it has to run as a separate service).

Post Reply