problem with gethostbyname/1

Raimo Niskanen raimo@REDACTED
Tue Oct 14 09:10:40 CEST 2003


Hi,

could you please try {lookup,["native","file"]} also.

The "native" resolver uses the built-in (native) resolver in the OS. 
This is what generally works best, especially in comparision to 
non-erlang applications. The "file" option is just a fallback, the 
"native" resolver also most probably uses the /etc/host file at some 
point, which is what the "file" option does.

If the "native" resolver does not work fine, you probably have a 
misconfigured Linux box. The fact that Erlang before your change had an 
empty lookup option also suggests that something in your network 
configuration may be weird. The default Erlang behaviour is to mimic the 
native resolver, but internally, since before R9B (I think) the native 
resolver had performance problems. Not anymore.

If you keep using the "dns" option, be warned that you are using an 
internal DNS client that may not behave as the rest of the applications 
on the Linux box (that uses the native resolver).

I have never come across a Gentoo Linux box before. Could you dump the 
following files as well as the output from os:type() and send to me?

/etc/hosts
/etc/resolv.conf
/etc/host.conf
/etc/nsswitch.conf
/etc/irs.conf

If you know of some other /etc file that Gentoo Linux uses for network 
configuration that is not among the above, throw it in too.

Sorry about the lack of documentation, but this part of the system is 
just a mess that we have wanted to rewrite for a long time, but dare not 
since it might break for some paying customer. Therefore we have not 
come around to documenting it either.

-- 
/ Raimo Niskanen, Erlang/OTP, Ericsson AB



david wallin wrote:
> Sean,
> 
> This is on my Linux box (before):
> 
> Eshell V5.3  (abort with ^G)
> 1> inet_db:res_option(lookup).
> []
> 
> I added '{lookup, ["file","dns"]}.' to the '.inetrc' file, and now 
> gethostbyname/1 works like a charm. Even net_adm:ping/1 works, which is 
> nice :-)
> 
> thanks a million,
> 
> --david.
> 
> 
> 
> On Monday, October 13, 2003, at 08:46 PM, Sean Hinde wrote:
> 
>>
>> On Monday, October 13, 2003, at 08:22  pm, David Wallin wrote:
>>
>>> Hi all,
>>>
>>> This is under Gentoo Linux (2.4.20) Pentium 4, could someone give me 
>>> a clue as to why this happens:
>>>
>>> Eshell V5.3  (abort with ^G)
>>> 1> inet:gethostbyname("wintermute").
>>> {error,nxdomain}
>>> 2> inet_res:gethostbyname("wintermute").
>>> {ok,{hostent,"wintermute.csis.ul.ie",[],inet,4,[{136,201,24,71}]}}
>>> 3> halt().
>>>
>>
>> Erlang has a ton of different ways to do name lookup, though the whole 
>> mechanism for choosing which one(s) are used appear to be 
>> undocumented, and it involves digging around in all sorts of UNIX 
>> files in /etc and elsewhere. You can find out which methods are being 
>> used with
>>
>> 1> inet_db:res_option(lookup).
>> [native,file]
>>
>> (example from my mac)
>>
>> And force a setting by creating a .inetrc file in your home directory 
>> containing:
>>
>> {lookup, ["native", "file"]}.
>>
>> Options appear to be:
>>
>> "bind", "dns", "hosts", "files", "file", "yp", "nis", "nisplus", "native"
>>
>> Some mechanisms appear to use internal dns code, others spawn external 
>> port programs. It is a bit of a minefield but there may be enough 
>> clues to sort it out.
>>
>> My sympathies!
>>
>> Sean
> 
> 




More information about the erlang-questions mailing list