How to get external (WAN) IP?

K

kimiraikkonen

Hi,
I'm connected through router and i have a local ip address as well
starting with 192.168.x.x. However i can read local ip address fine
with that code:

Dim strHostName As String
Dim strIPAddress As String
strHostName = System.Net.Dns.GetHostName()
strIPAddress =
System.Net.Dns.Resolve(strHostName).AddressList(0).ToString()
MessageBox.Show("Host Name: " & strHostName & "; IP Address: " &
strIPAddress)


But i want to get the external IP, the IP between router and ISP (WAN
ip) in VB.NET using System.Net namespace which must be the same as
shown on "whatismyip.com".

What's the simpliest way?

Thanks
 
M

Mr. Arnold

kimiraikkonen said:
Hi,
I'm connected through router and i have a local ip address as well
starting with 192.168.x.x. However i can read local ip address fine
with that code:

Dim strHostName As String
Dim strIPAddress As String
strHostName = System.Net.Dns.GetHostName()
strIPAddress =
System.Net.Dns.Resolve(strHostName).AddressList(0).ToString()
MessageBox.Show("Host Name: " & strHostName & "; IP Address: " &
strIPAddress)


But i want to get the external IP, the IP between router and ISP (WAN
ip) in VB.NET using System.Net namespace which must be the same as
shown on "whatismyip.com".

What's the simpliest way?


Dim WC As New System.Net.WebClient

TextBox1.Text =
System.Text.Encoding.ASCII.GetString((WC.DownloadData("http://whatismyip.com/automation/n09230945.asp")))

WC.Dispose()
 
K

kimiraikkonen

Dim WC As New System.Net.WebClient

TextBox1.Text =
System.Text.Encoding.ASCII.GetString((WC.DownloadData("http://whatismyip.com/automation/n09230945.asp")))

WC.Dispose()

Thanks! That works, however before posting i've heard similiar methods
about translating ip checker's web-content info VB app as string but i
supposed that an internal system.net namespace provides a function for
this, maybe there isn't.

Is that code special for "whatismyip.com" or other ip-checker sites
can be used for that purpose?
 
M

Mr. Arnold

kimiraikkonen said:
Thanks! That works, however before posting i've heard similiar methods
about translating ip checker's web-content info VB app as string but i
supposed that an internal system.net namespace provides a function for
this, maybe there isn't.

Is that code special for "whatismyip.com" or other ip-checker sites
can be used for that purpose?

I guess you'll have to find out about other such providers and what they
have to offer.

Routers use scripting languages like ASPscript or Javscript, that's how you
would get the IP from the router's WAN interface.
 
K

keyur

I guess you'll have tofindout about other such providers and what they
have to offer.

Routers use scripting languages like ASPscript or Javscript, that's how you
would get theIPfrom the router's WAN interface.

This is not possible.
here u have to use web service..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top