[erlang-questions] inet:gethostbyname question

Raimo Niskanen raimo+erlang-questions@REDACTED
Thu Jan 21 09:43:26 CET 2010


On Wed, Jan 20, 2010 at 10:11:39AM -0800, Yogish Baliga wrote:
> 
> On Mon, Jan 18, 2010 at 09:21:06PM -0800, Yogish Baliga wrote:
> > 
> > Which R13 release is it? The code involved was
> > extensively rewritten in R13B02.
> > 
> > Using latest version of R13.
> > 
> > And what does inet_db:gethostname() acutally return?
> > 
> > 
> > inet_db:gethostname() return gw06
> > 
> 
> Then we continue with these commands:
>     erlang:system_info(system_version).
>     application:get_env(kernel, inetrc).
>     node().
>     inet_db:gethostname().
>     io:format("~p~n", [ets:tab2list(inet_db)]).

Oh, I was unclear, I wanted to see the output of those commands...

> immediately after starting a node, and then after
> your fix by calling inet_config:init():
>     inet_db:gethostname().
>     io:format("~p~n", [ets:tab2list(inet_db)]).

And those...

> again, and we'll see what changed...
> 
> 
>    ***** Nothing changed after inet_config:init(). 

Previously you stated that the return values of
inet_db:res_option(search) and inet_db:res_option(domain)
changed after calling inet_config:init(), and those
are among the entries in the ets table inet_db, so
now you are contradicting yourself or just missed
that little change... Can I see the complete outputs, please?

> 
> Try also to start a fresh node, check ets:i(inet_db)
> to see that the table is as above. Then call
> inet_res:gethostbyname("gw06") and then:
>     inet_db:gethostname().
>     io:format("~p~n", [ets:tab2list(inet_db)]).
> to see if that call changes something...
> 
>   ************* Nothing changed after this too.
> 
> > > 
> > > inet_db:res_option(lookup).
> > > [dns,native,file].
> > > inet:gethostbyname(inet_db:gethostname())
> > > {error,nxdomain}
> > > inet_db:set_lookup([dns]).
> > > inet:gethostbyname(inet_db:gethostname())
> > > {ok,{hostent,"gw06",[],inet,4,[{127,0,0,1}]}}
> 
> Try the individual resolver components:
>     inet_res:gethostbyname("gw06").
> {ok, {hostent.....}} [works]
> 
>     inet_gethost_native:gethostbyname("gw06").
> {error, not_found}.
> 
>     inet_hosts:gethostbyname("gw06").
> {error,nxdomain}
> 
> and we'll see what they think.
> 
> Looks like dns resolver work but the native and file resolver does not work. 
> 
> For the native resolver, I tried remvoing "domain" line from /etc/resolv.conf. It seems to be working.

And the contents of /etc/resolv.conf is also interesting
to explain the native resolver and on some systems
/etc/nsswitc.conf. As is the contents of /etc/hosts...

And, of course, what is your operating system:
   1> os:type()
and
   $ uname -a

> 
> In R13, default lookup is [native] and in R12 is [native,file].
> 
> Setting lookup to [native,file] in R13 does not work either.
> 
> In both versions, dns resolver works.
> 
> For the time being, I am removing domain entry from /etc/resolv.conf file.
> 
> Thanx,
> -- baliga
> 
> > > 
> > > Having lookup method to 3 elements [dns,native,file] is not working. If I set it to only "dns", it is working. Also noticed that
> > > 
> > > inet_db:res_option(search).
> > > []
> > > inet_db:res_option(domain).
> > > "example.com"
> > > 
> > > Then I execute,
> > > 
> > > inet_config:init().
> > > 
> > > This function is called by inet_db:start_link(), which is called by kernel:init().
> > > 
> > > After executing inet_config:init(),
> > > 
> > > inet_db:res_option(search).
> > > ["sk1.example.com"].
> > > inet_db:res_option(domain).
> > > "example.com".
> > > 
> > >  
> > > After executing inet_config:init(), order of lookup methods doesn't matter. As long as I have dns in the list, it works.
> > > 
> > > inet:gethostbyname(inet_db:gethostname()).
> > > {ok,{hostent,"gw06.sk1.example.com",[],inet,4,[{127,0,0,1}]}}
> > > 
> > > Any idea, why inet_config:init() called by kernel->inet_db:start_link() is not working as expected?
> > > 
> > > Thanx,
> > > -- baliga
> > > 
> > > "Point of view is worth 80 IQ points" --Alan Kay
> > > 
> > > http://dudefrommangalore.blogspot.com/
> > -- 
> > 
> > / Raimo Niskanen, Erlang/OTP, Ericsson AB
> > 
> > ________________________________________________________________
> > erlang-questions mailing list. See http://www.erlang.org/faq.html
> > erlang-questions (at) erlang.org
> -- 
> 
> / Raimo Niskanen, Erlang/OTP, Ericsson AB

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB


More information about the erlang-questions mailing list