title: how to write a program to report the local IP address such as 192.168.1.102?
body: <p>since my Linksys router doesn't assign a fixed local IP to the computers (PC and Mac and Linux), i'd like to write a script so that every minute, the computers will update to each other so that</p>
  
  <p><a href="http://localhost/list.html" rel="nofollow noreferrer">http://localhost/list.html</a></p>
  
  <p>on each machine will contain a list of names of all PC and Mac and a link to their apache server (pointing to <a href="http://192.168.1.102" rel="nofollow noreferrer">http://192.168.1.102</a>, etc)</p>
  
  <p>it looks like a way to find out the local IP address is by ipconfig on PC, and ifconfig on the Mac and Linux, and to do it programmatically, it will be gethostbyname().</p>
  
  <p>But I tried on Ruby, that</p>
  
  <pre><code>irb(main):001:0&gt; require 'socket'
  =&gt; true
  
  irb(main):002:0&gt; p Socket::gethostbyname("localhost")
  ["Core2Duo", [], 2, "\177\000\000\001"]
  
  irb(main):005:0&gt; p Socket::gethostbyname("core2duo")
  ["Core2Duo", [], 2, "\300\250\001g"]
  =&gt; nil
  </code></pre>
  
  <p>and ipconfig actually shows</p>
  
  <pre><code>IPv4 Address. . . . . . . . . . . : 192.168.1.103
  </code></pre>
  
  <p>so is this the right way to do it?  I can hack it by executing "ipconfig" in Ruby and use regular expression to get the result, but would be nice to do it using a more standard way.</p>