WAN IP Address

S

ShaneO

Does anyone know how to obtain the WAN/Public IP Address (not LAN) using
VB .NET 2005?

I have an existing Service, which I wrote, that cheats by using
System.Net.WebClient to access a Remote Server, but I would now like to
do it "properly" (maybe by interrogating the Router??) but can't seem to
find a way!

Yes, and despite millions of references on Google, it doesn't appear
that anyone has actually provided a solution.

Thank-you in advance for any assistance you are able to provide.

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
 
S

ShaneO

Terry said:
I used a web service to do it: You can view the code here:

http://boycot.no-ip.com/vb/GetInetIP.htm
Thank-you Terry for your reply. I also use something similar (see
below) and I guess I've now had to resign myself to the fact that it
can't be done any other way from within the Private Network. It's
surprising though, as one would expect that a standard would have been
developed by now to retrieve such information directly from the Router,
oh well, maybe in the future....???

My current method -

Dim WebAccessClient As New System.Net.WebClient
Dim sIP as String =
WebAccessClient.DownloadString("http://www.whatismyip.com/")
WebAccessClient.Dispose()
Dim iFin As Integer
sIP = sIP.ToUpper
Dim iStart As Integer = sIP.IndexOf("YOUR IP IS ")
If iStart > 0 Then
iStart += 12
iFin = (sIP.IndexOf("</H1>", iStart)) + 1
sIP = Strings.Mid(sIP, iStart, iFin - iStart)
End If


ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
 
G

Guest

I have an existing Service, which I wrote, that cheats by using
System.Net.WebClient to access a Remote Server, but I would now like to
do it "properly" (maybe by interrogating the Router??) but can't seem to
find a way!

The only way to get it from the router would be through UPNP. But not all
routers implement UPNP properly, so I'm not sure how hard it will be to do.

To make things more complex, not all routers support UPNP and many have it
disabled by default. Thus it's probably easiest to query an external server
:)
 
G

Guest

Thank-you Terry for your reply. I also use something similar (see
below) and I guess I've now had to resign myself to the fact that it
can't be done any other way from within the Private Network. It's
surprising though, as one would expect that a standard would have been
developed by now to retrieve such information directly from the Router,
oh well, maybe in the future....???

UPNP, SNMP... there are in fact several standards - but none that are 100%
supported.
 
S

ShaneO

Spam said:
UPNP, SNMP... there are in fact several standards - but none that are 100%
supported.
Thank-you Spam Catcher,

My use of the term "standard" should have read as "common method" or
"agreed method". I'm certainly aware of the various communication
protocols that are in use, but as you wrote, none of them are of any
good unless everyone agrees on a method to expose the information that
someone might be seeking. Afterall, using WMI I can find out the type
of CPU and how much RAM is fitted in a system located on the other side
of the planet, but I can't interrogate a Router sitting on my desk to
find out my Public IP Address - it seems a bit strange!

Just my opinion.

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
 

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

Similar Threads


Top