How to use all nameservers in resolv.conf

Issues related to configuring your network
Post Reply
davewithheld
Posts: 3
Joined: 2022/08/13 04:43:08

How to use all nameservers in resolv.conf

Post by davewithheld » 2022/11/23 22:06:50

I am running a CentOS 8 Stream server in a factory filled with Windows clients and need to resolve their hostnames from the IPs that access my server. I am not running any networking services on my server: that is handled by our corporate I.T. "professionals". Unfortunately, their DHCP/DNS system (Windows DCs) does not propagate changes very well and I have intermittent problems with nslookup finding the hostnames. Nslookup on the Windows systems do not seem to have this problem. I am running out-of-the box DHCP-based networking with NetworkManager on the LAN, but it is a high availability, 2-node cluster with a second, private network for corosync and DRBD communications that is static. The LAN interface is used for the server's virtual IP, as well as all other network communications via its DHCP-assigned IP.

The DHCP server has supplied my server with four nameserver IPs and I have found that if I try all of them, I eventually get a hostname for the IP, but which nameserver works is often not the first in the DHCP-supplied list (contents of resolv.conf) and, apparently, the resolver on CentOS 8 is only checking the first nameserver that responds (?) and if that server does not have the IP, it does not resolve. Is there a way to configure my server to keep trying name servers until it either has tried them all or gets a hostname? I use nslookup for my scripts and testing, but I need the OS to be able to resolve a hostname so apps I don't have control over can also resolve the hostname. Does NetworkManager have a command or configuration setting to enable this?

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

Re: How to use all nameservers in resolv.conf

Post by TrevorH » 2022/11/23 22:43:36

The details of how it works are in man resolv.conf and yes, any answer at all from a nameserver, even if it's "dunno that" counts as a correct response. There are options you can specify, maybe some of those will help. The real answer is to get a nameserver that works.
CentOS 8 died a premature death at the end of 2021 - migrate to Rocky/Alma/OEL/Springdale ASAP.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are dead, do not use them.
Use the FAQ Luke

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

Re: How to use all nameservers in resolv.conf

Post by jlehtone » 2022/11/24 08:32:17

The default resolver in glibc reads only three nameserver entries.
davewithheld wrote:
2022/11/23 22:06:50
Does NetworkManager have a command or configuration setting to enable this?
Yes, the dns config option. See man NetworkManager.conf for possible values.

I have added config file /etc/NetworkManager/conf.d/00-dns.conf on my systems and it has:

Code: Select all

# ansible #
[main]
dns=dnsmasq
If I would need to change config of that dnsmasq instance (that Networkmanager.service starts),
I would add a config file to /etc/NetworkManager/dnsmasq.d/

(One of the other resolvers listed for option 'dns' could be better, but I was semi-familiar with dnsmasq.)

davewithheld
Posts: 3
Joined: 2022/08/13 04:43:08

Re: How to use all nameservers in resolv.conf

Post by davewithheld » 2022/11/25 19:32:27

google searches have indicated that dnsmasq is the only solution, but I would like to avoid adding yet another (non-trivial) service to a cluster that needs to be kept identical on both nodes. I have a workaround in place, now, that maintains resolv.conf independent of NetworkManager/DHCP and would rather stick with this simpler system. Thanks anyway.

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

Re: How to use all nameservers in resolv.conf

Post by jlehtone » 2022/11/25 21:22:18

Simpler? You still have to configure the NetworkManager so that it does not modify the resolv.conf and you have to do that "on both nodes". That requires about as much work as the "dns=dnsmasq".


If you desire to keep multiple machines with "identical" config, then I strongly recommend taking into use one of the configuration management systems. My config revealed that I do use Ansible, but there are others too. For example, Chef and Puppet.

Post Reply