If you want your external IP address, use an external service:
http://www.whatismyip.com/[
^]
Send a get request to the URL above and strip out the IP address, or even get the IP address from the Title of the page:
(?<=<TITLE>.*)\d*\.\d*\.\d*\.\d*(?=</TITLE>)
OK for those who want it:
using System.Net;
using System.Text;
namespace DreamInCode.Snippets
{
public static class IPFinder
{
private static readonly UTF8Encoding utf8 = new UTF8Encoding();
public static IPAddress ExternalIPAddress
{
get
{
string whatIsMyIp = "http://automation.whatismyip.com/n09230945.asp";
WebClient wc = new WebClient();
string response = utf8.GetString(wc.DownloadData(whatIsMyIp));
IPAddress myIPAddress = IPAddress.Parse(response);
return myIPAddress;
}
}
}
}
My source:
http://www.dreamincode.net/code/snippet959.htm[
^]
NOTE: The source page has the OLD automation address - use the snippet above which I have modified to use the new one.