How do I find my own IP address?

Björn Bylander bjorn@REDACTED
Thu Jan 22 17:44:10 CET 2004


Samuel Rivas wrote:

> If the name of possible interfaces bothers you, there is another
> (and undocumented too) function that will return an interesting list:
> 
> 1> inet:getiflist(S).
> {ok,["lo","eth0"]}
> 
> The real problem is those functions are not in the public API, so they
> could be changed in future releases.
> 
> Finally I've no idea of how Windows names its interfaces, and no
> chance to test getiflist in a Windows host ...

Results from a Windows machine:

Erlang (BEAM) emulator version 5.3 [threads:0]

Eshell V5.3  (abort with ^G)
1> {ok, S} = inet_udp:open(0, []).
{ok,#Port<0.30>}
2> inet:getiflist(S).
{ok,["50.240.861.291","100.0.0.721"]}
3>

The IP addresses on this machine are 127.0.0.1 (of course) and 
192.168.42.50...

Regards
Björn




More information about the erlang-questions mailing list