Reputation: 85
I did try to get internet IP by using GetIp method (below) but it only get one IP that's 123.22.114.5 , I restarted my modem many times but it still 123.22.114.5, please help me. (I'm using visual studio 2010 in windows 7 64bit)
(sorry about my bad english)
private string GetIp()
{
string extenalIp = "";
string whatIsMyIp = "http://automation.whatismyip.com/n09230945.asp";
string getIpRegex = @"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b";
WebClient wc = new WebClient();
UTF8Encoding utf8 = new UTF8Encoding();
string requestHtml = "";
try
{
requestHtml = utf8.GetString(wc.DownloadData(whatIsMyIp));
}
catch (Exception e)
{
// do some thing with exception
Console.WriteLine(e.Message);
}
Regex r = new Regex(getIpRegex);
Match m = r.Match(requestHtml);
if (m.Success)
{
extenalIp = m.Value.ToString();
}
wc.Dispose();
return extenalIp;
}
Upvotes: 0
Views: 208
Reputation: 46728
You would get just one IP which is your ISP's external IP address, when you request some external website like whatismyip.
All ISPs have limited static IP addresses and hosts facing the internet. That WAN IP address is shared among many users usually.
The IP you see there is completely different from your local IP address, and hence, restarting your modem won't change it.
Upvotes: 1