Page 1 of 1

how to prioritize localhost /etc/hosts as DNS

Posted: Sun May 06, 2018 1:56 am
by zaji_nms
Dear Expert

In /etc/resolv.conf , we have 3 DNS, one of DNS was having issue, due to this issue, nearly all HOSTs giving error : "Plugin timed out after 10 seconds".
We removed (disabled) that DNS (10.20.30.40) from this /etc/resolv.conf file and issue got fixed.

FYI, we are not fully depend on this DNS server (10.20.30.40) to resolve the HOSTs. We rely on our localhost DNS (/etc/hosts file), so how to prioritize localhost DNS (/etc/hosts) file to be our Prime DNS to resolve Nagios HOSTs? You know it will never fail.

Regards

Re: how to prioritize localhost /etc/hosts as DNS

Posted: Mon May 07, 2018 12:13 pm
by tgriep
The file that controls the order in which lookups are done is this file.

Code: Select all

/etc/nsswitch.conf
The option that controls the order of the look ups is the hosts: option.
If the option is set like below, it should look in the hosts file first and if it cannot find the host, it will do a DNS lookup.

Code: Select all

hosts:      files dns
Fore more details, you can look at the MAN page.
http://man7.org/linux/man-pages/man5/ns ... onf.5.html

Re: how to prioritize localhost /etc/hosts as DNS

Posted: Wed May 09, 2018 4:00 am
by zaji_nms
Dear tgriep

We checked and found the setting is same what you suggest/recommended. Its already there, even though why the plugin time out alert generated?

more /etc/nsswitch.conf | grep hosts
#hosts: db files nisplus nis dns
hosts: files dns

Regards

Re: how to prioritize localhost /etc/hosts as DNS

Posted: Wed May 09, 2018 11:11 am
by tmcdonald
This is more of a general Linux/networking question than a Nagios question. As far as I know we don't touch anything related to DNS on install or upgrade. You would do best to find a network admin to look into this issue, as it is somewhat out of scope for what we support.