DNS lookup failing even though resolv.conf is correct

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
User avatar
snapon_admin
Posts: 952
Joined: Mon Jun 10, 2013 10:39 am
Location: Kenosha, WI
Contact:

Re: DNS lookup failing even though resolv.conf is correct

Post by snapon_admin »

I already tried that and it still doesn't work, the trap still shows up under unconfigured objects with the IP as the host. I also can't try the other solution because I don't know what you mean by make sure it's the right order. Are you talking about this part?

Code: Select all

hosts:      files dns
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: DNS lookup failing even though resolv.conf is correct

Post by avandemore »

Yes, what are contents /etc/hosts and /usr/local/nagios/etc/hosts/lisgrid01p.cfg
Previous Nagios employee
User avatar
snapon_admin
Posts: 952
Joined: Mon Jun 10, 2013 10:39 am
Location: Kenosha, WI
Contact:

Re: DNS lookup failing even though resolv.conf is correct

Post by snapon_admin »

Code: Select all

[root@lisl-ngos-01-pv etc]# cat /etc/hosts
127.0.0.1       localhost.localdomain   localhost.localdomain   localhost4      localhost4.localdomain4 localhost
::1     localhost.localdomain   localhost.localdomain   localhost6      localhost6.localdomain6 localhost
10.245.128.172  lisl-ngos-01-pv lisl-ngos-01-pv.snapon.com      lisl-ngos-01-pv
10.245.0.1      USSNAPLSAIL-Core

Code: Select all

[root@lisl-ngos-01-pv etc]# cat /usr/local/nagios/etc/hosts/lisgrid01p.cfg
###############################################################################
#
# Host configuration file
#
# Created by: Nagios Core Config Manager 2.6.0
# Date:       2016-12-05 13:03:08
# Version:    Nagios 3.x config file
#
# --- DO NOT EDIT THIS FILE BY HAND --- 
# Nagios CCM will overwrite all manual settings during the next update if you 
# would like to edit files manually, place them in the 'static' directory or 
# import your configs into the CCM by placing them in the 'import' directory.
#
###############################################################################

define host {
        host_name                       lisgrid01p
        use                             solaris-server
        alias                           Lisle, IL Grid Monitoring server (Traps)
        address                         lisgrid01p.snapon.com
        max_check_attempts              5
        check_interval                  5
        retry_interval                  1
        check_period                    xi_timeperiod_24x7
        notification_interval           60
        notification_period             xi_timeperiod_24x7
        icon_image                      solaris.png
        _xiwizard                       passiveobject
        register                        1
        }

###############################################################################
#
# Host configuration file
#
# END OF FILE
#
###############################################################################
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: DNS lookup failing even though resolv.conf is correct

Post by eloyd »

TL;DR (no clue if this applies, but this leaped out at me from the beginning of this thread):

Are you sure your DNS zones are correct? resolv.conf does not query servers until it gets a result, it queries servers until it doesn't get a timeout. So a null result (ie, IP not found) is a non-null result and it will stop querying the list of servers in your resolv.conf file.

"The algorithm used is to try a name server, and if the query times out, try the next, until out of name servers, then repeat trying all the name servers until a maximum number of retries are made."

If you want to spread the load out, you must use the rotate option:

"sets RES_ROTATE in _res.options, which causes round-robin selection of nameservers from among those listed. This has the effect of spreading the query load among all listed servers, rather than having all clients try the first listed server first every time."
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: DNS lookup failing even though resolv.conf is correct

Post by avandemore »

Yeah so you still have no host called the name the trap is coming is as. As said before, it will not work as is.
Previous Nagios employee
User avatar
snapon_admin
Posts: 952
Joined: Mon Jun 10, 2013 10:39 am
Location: Kenosha, WI
Contact:

Re: DNS lookup failing even though resolv.conf is correct

Post by snapon_admin »

It has worked this way for 2 years...
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: DNS lookup failing even though resolv.conf is correct

Post by eloyd »

Okay, but for fun, change:

Code: Select all

        host_name                       lisgrid01p
to

Code: Select all

        host_name                       lisgrid01p.snapon.com
And see what happens.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
User avatar
snapon_admin
Posts: 952
Joined: Mon Jun 10, 2013 10:39 am
Location: Kenosha, WI
Contact:

Re: DNS lookup failing even though resolv.conf is correct

Post by snapon_admin »

I have already done that, I think I stated that earlier but I might be mistaken. It didn't change anything. I just had my DBA retest by sending another trap, and this time the host resolved with the proper name. And, as I stated earlier, the .snapon.com suffix was not necessary in the host_name field. As shown here, it drops the suffix anyway. This is what happened when the host_name was set to lisgrid01p.snapon.com:
traps broken.png
The suffix is dropped so this trap was sent to unconfigured objects since the hostname includes the suffix. That was what I was trying to say earlier. So this is working now, but I still have a problem with the DNS resolution, though now I'm thinking it might be a CentOS issue and not a Nagios one, so I am not sure if you can fix this. I modified the resolv.conf file yesterday to put one Unix DNS server and one Windows DNS server into it, with the Unix server listed on top. It took until this morning for this to actually work as expected which is kind of an issue. Again, it may not be a Nagios issue though, I'm assuming /etc/resolv.conf is a CentOS thing and not a Nagios thing but feel free to correct me if I'm wrong there.
You do not have the required permissions to view the files attached to this post.
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: DNS lookup failing even though resolv.conf is correct

Post by eloyd »

/etc/resolv.conf is very much a Unix thing, not a Nagios thing. Things to check if your DNS is not resolving properly are to make sure the zones are properly loaded with correct serial numbers, that the resolvers are running on the DNS servers, and that your TTL is set to a time frame that make sense for your organization.

And, as my pappy used to say, "If DNS ain't workin', ain't nobody workin'."
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
User avatar
snapon_admin
Posts: 952
Joined: Mon Jun 10, 2013 10:39 am
Location: Kenosha, WI
Contact:

Re: DNS lookup failing even though resolv.conf is correct

Post by snapon_admin »

Well DNS was always working per se. The problem was that the etc/resolv.conf file doesn't seem to like going through the list of servers like it says it's supposed to. If the Unix DNS server is listed first, I'll get a proper result. If it's listed second or later, I won't. Thats' the problem I have with resolv.conf. It's not an issue on our DNS servers otherwise believe me, we'd have bigger issues here.
Locked