[c#] How to get the IP address of the server on which my C# application is running on?

Yet another way to get your public IP address is to use OpenDNS's resolve1.opendns.com server with myip.opendns.com as the request.

On the command line this is:

  nslookup myip.opendns.com resolver1.opendns.com

Or in C# using the DNSClient nuget:

  var lookup = new LookupClient(new IPAddress(new byte[] { 208, 67, 222, 222 }));
  var result = lookup.Query("myip.opendns.com", QueryType.ANY);

This is a bit cleaner than hitting http endpoints and parsing responses.