There is no built-in way to do this within the framework, because it is difficult to determine what an external / public IP address is. This, of course, assumes that your IP address belongs to NAT behind some gateways.
One way would be to clean the site, for example http://www.whatismyip.org/ , using WebClient .
System.Net.WebClient client = new System.Net.WebClient(); string ip = client.DownloadString( "http://www.whatismyip.org" ); Console.Out.WriteLine( ip );
source share