title: C# - Getting Current Public IP Address
body: <p>I believe this question may be quickly flagged as a duplicate. However, I do believe this is a legitimate question.</p>
  
  <p>At this time, I'm getting my current IP address using the following code:</p>
  
  <pre><code>IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
  IPAddress currentIpAddress = hostEntry.AddressList.FirstOrDefault(address =&gt; address.AddressFamily == AddressFamily.InterNetwork);
  Console.WriteLine(currentIpAddress.ToString());
  </code></pre>
  
  <p>When I run this code, I get the first Ethernet adapter value I see when I run <code>ipconfig</code> from a command-line. However, this value is different than the IP address I see when I run a query for "what is my ip address" on Google. I don't understand why these values are different. For that reason, I'm concerned that my code is incorrect.</p>
  
  <p>How do I know if my code is correctly getting the IP address of the machine the app is currently running on? </p>