Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Jun 2000 14:50:27 -0700 (MST)
From:      "Chad R. Larson" <chad@DCFinc.com>
To:        jedgar@fxp.org (Chris D. Faulhaber)
Cc:        scrappy@hub.org, freebsd-stable@FreeBSD.ORG
Subject:   Re: DNS problem with 4.0-STABLE?
Message-ID:  <200006052150.OAA08843@freeway.dcfinc.com>
In-Reply-To: <Pine.BSF.4.10.10006051223030.42261-100000@pawn.primelocation.net> from "Chris D. Faulhaber" at "Jun 5, 0 12:27:25 pm"

next in thread | previous in thread | raw e-mail | index | archive | help

--ELM960241827-8810-0_
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

As I recall, Chris D. Faulhaber wrote:
> Most userland programs (e.g. ping) use host.conf to determine how to
> resolve hostnames.  nslookup talks directly to nameservers (i.e. doesn't
> use host.conf).

I got bitten by exactly the same problem.  A program (NetBackup, in
this case) was claiming it couldn't connect with its master server,
where nslookup/host returned the correct address and ping could ping
it.

Turns out the system =was= configured to look in the hosts file
first, and the hosts file had an incorrect entry.  That effectively
overrode the correct DNS response.  I believe this is referred to as
"namespace overloading", and in some instances I can see it being a
good thing.

Anyway, I built this simple program to help diagnose such problems
in the future.  It gets a host address the same way most
applications do, by calling "gethostbyaddr(3)" instead of calling
the resolver routines "res_query(3)".

It's a quick-n-dirty; no man page.  But it works and is useful.

Perhaps I'll submit it as a port...

	-crl
--
Chad R. Larson (CRL15)   602-953-1392   Brother, can you paradigm?
chad@dcfinc.com         chad@larsons.org          larson1@home.net   
DCF, Inc. - 14623 North 49th Place, Scottsdale, Arizona 85254-2207

--ELM960241827-8810-0_
Content-Type: application/x-shar
Content-Disposition: attachment; filename=gethost.shar
Content-Description: gethostbyaddr lookup program
Content-Transfer-Encoding: 7bit

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	gethost.c
#	Makefile
#
echo x - gethost.c
sed 's/^X//' >gethost.c << 'END-of-gethost.c'
X/* $Id: gethost.c,v 1.1 2000/05/17 04:52:06 chad Exp $*/
X
X/*
X * Print the "hostent" information for every host whose name is
X * specified on the command line.
X */
X
X#include	<stdio.h>
X#include	<sys/types.h>
X#include	<netdb.h>		/* for struct hostent */
X#include	<sys/socket.h>		/* for AF_INET */
X#include	<netinet/in.h>		/* for struct in_addr */
X#include	<arpa/inet.h>		/* for inet_ntoa() */
X
X#define FALSE 0
X#define TRUE ~FALSE
X
Xmain(argc, argv)
Xint	argc;
Xchar	**argv;
X{
X	register char		*ptr;
X	register struct hostent	*hostptr;
X	int			tcp_flag = FALSE;	/* stream or dgram ? */
X
X	if (argc < 2) {
X	    printf("Usage: %s hostname [...]\n", argv[0]);
X	    exit(1);
X	}
X
X	if (argc > 2) {	/* use virtual circuit if more than one query */
X	    tcp_flag = TRUE;
X	    sethostent(TRUE);
X	}
X
X	while (--argc > 0) {
X		ptr = *++argv;
X		if ( (hostptr = gethostbyname(ptr)) == NULL) {
X		    printf("gethostbyname error for host %s: ", ptr);
X		    err_ret(h_errno);
X			continue;
X		}
X		printf("\nOfficial host name: %s\n", hostptr->h_name);
X
X		/* go through the list of aliases */
X		while ( (ptr = *(hostptr->h_aliases)) != NULL) {
X			printf("	alias: %s\n", ptr);
X			hostptr->h_aliases++;
X		}
X
X		switch (hostptr->h_addrtype) {
X		case AF_INET:
X			pr_inet(hostptr->h_addr_list, hostptr->h_length);
X			break;
X
X		default:
X			printf("unknown address type");
X			break;
X		}
X	}
X	if (tcp_flag)
X	    endhostent();
X}
X
X/*
X * Go through a list of Internet addresses,
X * printing each one in dotted-decimal notation.
X */
X
Xpr_inet(listptr, length)
Xchar	**listptr;
Xint	length;
X{
X	struct in_addr	*ptr;
X
X	while ( (ptr = (struct in_addr *) *listptr++) != NULL)
X		printf("	Internet address: %s\n", inet_ntoa(*ptr));
X}
X
X/*
X * Display hostent error code
X */
X
Xerr_ret(err)
Xint	err;
X{
X    switch (err) {
X	case HOST_NOT_FOUND:
X	    printf("Authoritative Answer Host not found\n");
X	    break;
X	case TRY_AGAIN:
X	    printf("Non-Authoritive Host not found, or server fail\n");
X	    break;
X	case NO_RECOVERY:
X	    printf("Non recoverable errors, FORMERR, REFUSED, NOTIMP\n");
X	    break;
X	case NO_DATA:
X	    printf("Valid name, no data record of requested type\n");
X	default:
X	    printf("Unknown error code %d\n", err);
X	    break;
X    }
X}
END-of-gethost.c
echo x - Makefile
sed 's/^X//' >Makefile << 'END-of-Makefile'
X# Makefile for the host name lookup program
X#  $Id: Makefile,v 1.1 2000/05/17 04:52:06 chad Exp $
X
XBINDIR =	/usr/local/bin
X
Xgethost:	gethost.o
X	$(CC) $(CFLAGS) gethost.o -o gethost
X
Xinstall:	gethost
X	install -C -s gethost $(BINDIR)
X
X.c.o:
X	$(CC) $(CFLAGS) -c $<
END-of-Makefile
exit


--ELM960241827-8810-0_--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200006052150.OAA08843>