[erlang-questions] How is hostname decided
Raimo Niskanen
raimo+erlang-questions@REDACTED
Fri Jun 27 08:57:45 CEST 2008
On Thu, Jun 26, 2008 at 05:36:45PM -0500, Anders Nygren wrote:
> When using short names, how is the hostname decided.
> The reason I am asking is that I have a system based on R12B2
> running on RedHat Enterprise 4
>
> [npas@REDACTED lib]$ /opt/npas/bin/erl -sname test
> Erlang (BEAM) emulator version 5.6.2 [source] [64-bit] [smp:2]
> [async-threads:0] [hipe] [kernel-poll:false]
>
> Eshell V5.6.2 (abort with ^G)
> (test@REDACTED)1> inet:gethostname().
> {ok,"npas"}
>
> Why is the nodename localhost, when inet:gethostname() returns npas?
>
> Looking through the sources I found what looks like the place where hostname is
> determined.
> inet_config:set_hostname() ->
> case inet_udp:open(0,[]) of
> {ok,U} ->
> Res = inet:gethostname(U),
> inet_udp:close(U),
> set_hostname(Res);
> _ ->
> set_hostname({ok, []})
> end.
>
> But that also gives "npas"
Further down in inet_config:init/0 comes a call to
standalone_host/0, and that might do tricks. It ensures
the hostname is resolvable.
What does the following OS commands tell you?
$ hostname -s
$ hostname -f
$ getent hosts npas
$ cat /etc/hosts
$ cat /etc/resolv.conf
$ cat /etc/nsswitch.conf
And what does the following Erlang commands tell you?
1> ets:tab2list(inet_db).
2> inet:gethostbyname("npas").
You probably have a somewhat strange resolver situation.
Freshly installed modern Linux machines often has.
We ought to write an FAQ entry about Elang/OTP's
desires about the host's resolver configuration
esp. for long node names.
Note that you can force a node name like this:
$ /opt/npas/bin/erl -sname test@REDACTED
>
> /Anders
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
--
/ Raimo Niskanen, Erlang/OTP, Ericsson AB
More information about the erlang-questions
mailing list