From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,b308574f9841b3bf X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2004-04-27 13:16:04 PST Path: archiver1.google.com!news1.google.com!news.glorb.com!newsfeed3.easynews.com!easynews.com!easynews!border1.nntp.sjc.giganews.com!border2.nntp.sjc.giganews.com!nntp.giganews.com!cyclone-sf.pbi.net!216.218.192.242!news.he.net!dimensional.com!pulsar.dimensional.com!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!news.cpqcorp.net!53ab2750!not-for-mail From: Brian Haley User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7b) Gecko/20040421 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.unix.tru64 Subject: Re: gethostbyname returns only single IP address References: <5d1678ff.0404220743.37a2d7e1@posting.google.com> <2as96c.7gf.ln@dadsys2.fuller.local> <5d1678ff.0404230504.2eb35ac4@posting.google.com> <5d1678ff.0404261254.5405fb4e@posting.google.com> <408D8D8C.3030801@nospam_hp.com> <5d1678ff.0404270854.6abdacbc@posting.google.com> In-Reply-To: <5d1678ff.0404270854.6abdacbc@posting.google.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Tue, 27 Apr 2004 20:36:32 GMT NNTP-Posting-Host: 16.141.88.143 X-Complaints-To: abuse@HP.com X-Trace: news.cpqcorp.net 1083098192 16.141.88.143 (Tue, 27 Apr 2004 13:36:32 PDT) NNTP-Posting-Date: Tue, 27 Apr 2004 13:36:32 PDT Organization: Hewlett-Packard Company Xref: archiver1.google.com comp.unix.tru64:11393 Ok, now it's making sense. Linux has a configuration parameter to control this behavior, from host.conf(5): (referring to /etc/host.conf file) multi Valid values are on and off. If set to on, the resolv+ library will return all valid addresses for a host that appears in the /etc/hosts file, instead of only the first. This is off by default, as it may cause a substantial performance loss at sites with large hosts files. The actual default on my Linux system was "on", when I turned it off I got the same behavior at Tru64. I don't think there is a similar switch on Tru64 as this doesn't seem to be part of any standard. You might want to try putting them both in DNS to see if that works. Sorry, I don't know that particular code very well. -Brian Calista wrote: > Brian, > > Here is the info. > > /etc/hosts file there are entries like this > > xxx.xx.xx.xx myhostname myhostalias1 > yyy.yy.yy.yy myhostname myhostalias2 > > /* PS: actual ip addrs\hostname are replaced with xxx yyy. etc */ > > So, I do a gethostbyname(myhostname). It returns only xxx.xx.xx.xx, in > other words only the first one listed in /etc/hosts file. > > I ran your code on Tru64 that also displays only xxx.xx.xx.xx > > So there must be some configuration option that I am missing. > Any ideas on how I can check my DNS configuration? > > Thanks Brian. > Calista. > > > > Brian Haley wrote in message news:<408D8D8C.3030801@nospam_hp.com>... > >>Calista wrote: >> >> >>>Yes Brian, I have tried the program on Linux, and there it prints both >>>of the IP addresses. It doesn't print both on Tru64 though. I suspect >>>the problem is with how the system is configured, but I have no idea >>>where\what to look for. >> >>You still haven't given enough configuration information - do the two IP >>addresses have different hostnames associated with them? I would not >>expect that to return more than one address unless there is some special >>DNS configuration. >> >>Just so we're on the same page, I've included an example gethostbyname() >>utility I use. >> >># ./gethostbyname `hostname` >> >>Oh, and my Linux box behaves like Tru64 :) >> >>-Brian >> >> >>#include >>#include >>#include >> >>void printhostent(); >>void print_h_errno(); >> >>main ( argc, argv ) >>int argc; >>char *argv[]; >>{ >> struct hostent *hp; >> >> if ( argc != 2 ) >> printf("Usage: gethostbyname host\n"); >> else if ( hp = gethostbyname(argv[1]) ) { >> printf("hp = 0x%lx\n", hp); >> printhostent(hp); >> } else >> print_h_errno(); >> >>} >> >> >>void >>printhostent ( hp ) >>struct hostent *hp; >>{ >> char **cpp; >> struct in_addr addr; >> >> printf("struct hostent:\n"); >> printf("\t h_name %s\n",hp->h_name); >> cpp = hp->h_aliases; >> if ( !*cpp ) >> printf("\t h_aliases\n"); >> else { >> printf("\t h_aliases %s\n",*cpp); >> while ( *++cpp ) >> printf("\t %s\n",*cpp); >> } >> printf("\t h_addrtype %d\n",hp->h_addrtype); /*** CONVERT TO >>MNEMONIC ***/ >> printf("\t h_length %d\n",hp->h_length); >> cpp = hp->h_addr_list; >> if ( !*cpp ) >> printf("\t h_addr_list\n"); >> else { >> addr.s_addr = **(u_int **)cpp; >> printf("\t h_addr_list %s\n",inet_ntoa(addr)); >> while ( *++cpp ) { >> addr.s_addr = **(u_int **)cpp; >> printf("\t %s\n",inet_ntoa(addr)); >> } >> } >>} >> >> >>void >>print_h_errno() >>{ >> char *msg; >> >> switch(h_errno) { >> case HOST_NOT_FOUND: >> msg = "HOST_NOT_FOUND"; >> break; >> case TRY_AGAIN: >> msg = "TRY_AGAIN"; >> break; >> case NO_RECOVERY: >> msg = "NO_RECOVERY"; >> break; >> case NO_ADDRESS: >> msg = "NO_ADDRESS"; >> break; >> default: >> msg = "unknown error code"; >> } >> printf("h_errno: %s\n",msg); >>}