title: How do I get the local IP address of a system?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/7212892/how-to-get-local-ip-address-using-vb">How to get local ip address using vb?</a>  </p>
  </blockquote>
  
  
  
  <p>I am using Silverlight3 with VB.NET. I have written the follwing code in my service file. When I run my project locally, it gives the IP address of my system as 192.168.1.12 successfully. But, when I host my project it wont return the IP adress of the system which I am using. </p>
  
  <p>ie: If i host my project in system A which is of ip 192.168.1.12 and if I access the project from system B which is of ip 192.168.1.7, the output of my project will gives the IP of system A (where i have hosted my project). It should give the IP of system B where am running it. Similarly, if am accessing the project from system C means it should give the IP of system C, but here it is returning the IP of system A.</p>
  
  <p>Kindly help me please.
  Thanks</p>
  
  <pre><code>Private Function fnLocalIp() As String
      Try
          Dim h As System.Net.IPHostEntry = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName)
          Dim strLocalIp As String = h.AddressList.GetValue(0).ToString
          Return strLocalIp
      Catch ex As Exception
      End Try
  End Function
  </code></pre>