On 2 August 2012 15:31, Raimo Niskanen
<
raimo+erlan...@erix.ericsson.se> wrote:
> On Thu, Aug 02, 2012 at 09:40:03AM +0100, Gustav Simonsson wrote:
>>
>> {ok, LocalHostName} = inet:gethostname().
>> inet_res:gethostbyname(LocalHostName).
>
> That forces using the OTP DNS resolver, which may be in conflict
> with the current node configuration. The first approach should be:
>
> {ok, LocalHostName} = inet:gethostname().
> inet:gethostbyname(LocalHostName).
>
That's clearly not what net_kernel is doing though:
==============================================
t4@frigg:x-test $ erl -name foobar
Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:4:4]
[async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9.1 (abort with ^G)
(
foo...@frigg.eng.mycorp.com)1>
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
(v)ersion (k)ill (D)b-tables (d)istribution
a
t4@frigg:x-test $ erl -name
foo...@frigg.eng.mycorp.com
Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:4:4]
[async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9.1 (abort with ^G)
(
foo...@frigg.eng.mycorp.com)1>
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
(v)ersion (k)ill (D)b-tables (d)istribution
a
t4@frigg:x-test $ erl
Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:4:4]
[async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9.1 (abort with ^G)
1> {ok, Host} = inet:gethostname().
{ok,"frigg"}
2> inet:gethostbyname(Host).
{ok,{hostent,"frigg",[],inet,4,[{127,0,0,1}]}}
3>
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
(v)ersion (k)ill (D)b-tables (d)istribution
a
t4@frigg:x-test $
==============================================
And the problem I've got is that whilst on this machine (CentOS 6.2,
R15B01-64bit) the network configuration is *somehow* set up so that
net_kernal magically picks up the right domain info, this doesn't work
consistently everywhere else. And neither does calling inet_rc, as
Gustav suggested:
==============================================
t4@frigg:x-test $ erl
Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:4:4]
[async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9.1 (abort with ^G)
1> {ok, LocalHostName} = inet:gethostname().
{ok,"frigg"}
2> inet_res:gethostbyname(LocalHostName).
{error,nxdomain}
3>
=============================================
On some other machines, inet_res:gethostbyname/1 returns {error, timeout}.