How can i get IP Address of my 3G modem?

You can get a list of your IP addresses via DNS using the following code:

var name = Dns.GetHostName();
var entry = Dns.GetHostEntry(name);
foreach (var address in entry.AddressList) {
Console.WriteLine(address);
}

If you want the IP address as a property of the hardware, you can use the System.Management.ManagementClass with the name Win32_NetworkAdapterConfiguration. See http://msdn.microsoft.com/en-us/library/system.management.managementclass.aspx for details.

4 down vote

You can use the static method WebClient.DownloadString(url) to read your external IP address from any web service providing such data:

string ip = System.Net.WebClient.DownloadString(“http://whatismyip.org/”);

If you are going to use this in a production environment, better make sure that the URL you are pointing to, is guaranteed to stay around for the entire lifespan of your application. The best way is probably to host the web service yourself.

Also, you should add some error checking around this code, as it will fail if the internet connection or the web service is unavailable.

1 down vote

You can create a WebRequest to http://whatismyip.com/automation/n09230945.asp which houses only your IP address

Start here

http://stackoverflow.com/questions/2272483/how-can-i-get-ip-address-of-my-3g-modem
http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx
http://msdn.microsoft.com/en-us/magazine/cc163692.aspx

About eagle081183

Passionate, Loyal
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s