how to prioritize localhost /etc/hosts as DNS

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
zaji_nms
Posts: 616
Joined: Tue Oct 16, 2012 12:28 am

how to prioritize localhost /etc/hosts as DNS

Post 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
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

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

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
zaji_nms
Posts: 616
Joined: Tue Oct 16, 2012 12:28 am

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

Post 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
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

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

Post 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.
Former Nagios employee
Locked