How to get external (WAN) IP?

  • Thread starter Thread starter kimiraikkonen
  • Start date Start date
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
 
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()
 
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?
 
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.
 
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..
 
Back
Top