How do I find my own IP address?

Joe Armstrong joe@REDACTED
Wed Jan 21 15:41:48 CET 2004


I need to know my own IP address

I can find my hostname

1> inet:gethostname().
{ok,"enfield"}

And do this

2> inet:gethostbyname("enfield").
 
{ok,{hostent,"localhost.localdomain",
             ["localhost","enfield"],
             inet,
             4,
             [{127,0,0,1}]}}

But 127.0.0.1 is not my IP address

The undocumented function inet:getif()
produces


4> inet:getif().
{ok,[{{193,10,65,254},{193,10,67,255},{255,255,252,0}},
     {{127,0,0,1},{127,255,255,255},{255,0,0,0}}]}

The first element of this list appears to be my IP address - 
can I reply on this????

/Joe




More information about the erlang-questions mailing list