[erlang-questions] inet:gethostbyname question

Raimo Niskanen <>
Wed Jan 20 09:23:38 CET 2010


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)]).
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)]).
again, and we'll see what changed...

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...

> > 
> > 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").
    inet_gethost_native:gethostbyname("gw06").
    inet_hosts:gethostbyname("gw06").
and we'll see what they think.

> > 
> > 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


More information about the erlang-questions mailing list