thanks you! steve! :)<br><br>
<div class="gmail_quote">2008/10/26 Steve Vinoski <span dir="ltr"><<a href="mailto:vinoski@ieee.org">vinoski@ieee.org</a>></span><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>
<div></div>
<div class="Wj3C7c">On 10/25/08, litao cheng <<a href="mailto:litaocheng@gmail.com">litaocheng@gmail.com</a>> wrote:<br>><br>> hi, everyone.<br>> I want to get the factual ip address of my host. when I use the<br>
> inet:gethostname earn my host name. and then use the inet:gethostbyname/1 or<br>> inet:getaddrs/2 to get the ip address. the results is : <a href="http://127.0.1.1/" target="_blank">127.0.1.1</a>.<br>> I can use the ifconfig to see the ip address of eth0 is <a href="http://192.168.1.101/" target="_blank">192.168.1.101</a>, I<br>
> want to get this value. how can I do it?<br>> btw, If it relate to the inetrc config of kernel app?<br>> (my computer os is ubuntu 8.04, OTP R12B4)<br><br></div></div>There's the following undocumented function:<br>
<br>1> inet:ifget("eth0", [addr]).<br>{ok,[{addr,{192,168,1,101}}]}<br><br>On Ubuntu "eth0" should work for you, but if you want to know what<br>interfaces you have:<br><br>2> inet:getiflist().<br>
{ok,["lo","eth0"]}<br><br>Also note you can change the IP address tuple to a string like this:<br><br>3> inet_parse:ntoa({192,168,1,101}).<br>"<a href="http://192.168.1.101/" target="_blank">192.168.1.101</a>"<br>
<br>and back again:<br><br>4> inet_parse:address("<a href="http://192.168.1.101/" target="_blank">192.168.1.101</a>").<br>{ok,{192,168,1,101}}<br><font color="#888888"><br>--steve<br></font></blockquote></div>
<br>