[Nagiosplug-devel] changes to host resolution behavior with AF-independent patches?

Jeremy T. Bouse jeremy+nagios at undergrid.net
Wed Mar 19 10:41:27 CET 2003


On Wed, Mar 19, 2003 at 09:48:46AM -0500, Karl DeBisschop wrote:
> The current CVS head seems to do name resolution differently than it
> used to (and not correctly, I think).
> 
> Jeremy - with a quick look, does it seem this might be a side effect of
> your AF-independent patches (I have not looked at the code yet, though I
> will if you don't recognize the change)
>
	This might be possible... Most of the plugins (check_http
included) call is_host() to verify if what is given is a valid IP
address or hostname... is_host() in turn called the seperate function to
check if it was a hostname [is_hostname()] or address[old:
is_dotted_quad(), new:is_addr() which calls is_inet_addr() and/or
is_inet6_addr()]...

	Technically is_inet_addr(), is_inet6_addr() and is_hostname()
are functionally the same now as they all call resolve_host_or_addr()
just specifing a differetn Address Family (AF_INET, AF_INET6, AF_UNSPEC
respectively). Then resolv_host_or_addr() calls the getaddrinfo()
function to get the address info for the name given to it (either name
or IP address (v4 or v6)... 

	It's possible that is_hostname() should be reworked to use the
resolver differently to take into account domain search paths which is
what I suspect is causing the last condition...
 
> I think that the last example should work.
> 
> $ host d1
> d1.infoplease.com has address 165.193.123.154
> $ check_http -I 165.193.123.154 -H www.infoplease.com
> HTTP OK HTTP/1.1 200 OK - 0.106 second response time |time=0.106
	This is as exected connecting to the IP address (-I) but using
the host (-H) within the URI request and using the Host: header

> $ check_http -I 165.193.123.154                    
> OK - HTTP/1.1 302 Found - 0.001 second response time |time=0.001
	This would be connecting to the same IP address but not sending
a Host: header as the -H option is not given...

> $ check_http -H 165.193.123.154 
> OK - HTTP/1.1 302 Found - 0.001 second response time |time=0.001
	This is functionally equivilent to the previous only it would
send a 'Host: 165.193.123.154" instead of "Host: www.infoplease.com" as
the first one would... 

> $ check_http -H d1              
> CRITICAL - Socket timeout after 10 seconds
	This is the suspect one... Did it actually resolve d1 to
d1.infoplease.com and resolve it's address to be 165.193.123.154 or not
would be the first step... Is there any sign of the connection attempt
being made? I believe it did or it would have given a usage error that
the hostname was not valid

$ ./check_http -H d1
Name or service not known

	What may be happening then is that because the -H option was
used it is sending "Host: d1" to the server which is then timing out
trying to look it up and respond back... I suspect if you had tried
'check_http -I d1 -H www.infoplease.com' it would succeed without a
problem or even 'check_http -I d1' which wouldn't even send the Host:
header...

	Can you confirm these findings?

	Jeremy




More information about the Devel mailing list