By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,107 Members | 1,607 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,107 IT Pros & Developers. It's quick & easy.

router ip address

P: n/a
anyone know how to get a network router's external ip address? any examples
w/b great!

tia,

steve
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"steve" <a@b.com> wrote in news:10*************@corp.supernews.com:
anyone know how to get a network router's external ip address? any
examples w/b great!


You'll need to contact an external source to retrieve the IP.

Or your router may have an internal interface with the IP address.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 20 '05 #2

P: n/a
actually, i've found 4 other ways...

1. use basic authentication in an http request to the router's web page that
shows its wan ip address and parse for it.
2. use microsoft's nat library.
3. use wmi.
4. use microsoft's upnp library.

of course, using some external site like showmyip.com would work...but i
can't guarantee they'll be up 100% of the time. thanks for your help just
the same. the easiest method seems to be getting a web page from the router
and parsing for the wan ip...since i've already got a great regexp for ip
address patterns, parsing won't be a big deal at all.

thanks again,

steve

"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn**************************@140.99.99.130...
| "steve" <a@b.com> wrote in news:10*************@corp.supernews.com:
|
| > anyone know how to get a network router's external ip address? any
| > examples w/b great!
|
| You'll need to contact an external source to retrieve the IP.
|
| Or your router may have an internal interface with the IP address.
|
| --
| Lucas Tam (RE********@rogers.com)
| Please delete "REMOVE" from the e-mail address when replying.
| http://members.ebay.com/aboutme/coolspot18/
Nov 20 '05 #3

P: n/a
This isn't really a good method since it needs to be changed router to
router.

Here are two slightly better alternatives:

You could hit an external website like http://www.whatismyip.com/ which will
return the user's public IP address. The only problem with this method is
that the site may go down or be otherwise unaccessable. Note you can create
your own website that will simply return the IP without the need for parsing
and it might be more reliable; however, it can still go down.

The other alternative which works very well if your router supports it, is
to use a dynamic dns service like dyndns.org. If your router supports this
function you can sign up for a free account and have an address like
<hostname>.dyndns.org. The router will then automatically refresh the IP
every so often. Resolving this dns entry will be the IP of the router.
Allowing the user to simply input the dns address to resolve will pretty
much cover every case so the user could use any service they desired..

If anyone can think of any other more generic solutions please post them,
but for now these are the best methods I can come up with.
"Brooke" <Br****@discussions.microsoft.com> wrote in message
news:90**********************************@microsof t.com...
Steve, I am not sure what router you have, but here is how I did it. If you hear of a better way, please let me know.

Oh, You will need to make a new form and add these properties
webbrowser - called WebBrowser1
label - called label1
timer - Timer1

---------------------------------------------------------
Option Explicit
Dim webtx As String

Private Function RefreshPage()
Dim K1 As Integer, k2 As Integer, k3 As Integer, result As Integer
Dim IPaddress1 As String, IPaddress2 As String
If WebBrowser1.Visible = True Then
WebBrowser1.Refresh
End If
webtx = WebBrowser1.Document.body.innertext
If Len(webtx) > 50 Then
K1 = InStr(1, webtx, "IP Address")
k2 = InStr(K1 + 11, webtx, "IP Address")
IPaddress1 = Mid(webtx, k2 + 11, 16)
k3 = InStr(IPaddress1, " ")
IPaddress2 = Mid(IPaddress1, 1, k3 - 1)
Else
result = MsgBox("Login Not Confirmed, Please Try Again", vbOKCancel) If result = 1 Then
WebBrowser1.Stop
Form_Load
Else
End
End If
End If
WebBrowser1.Visible = False
Label1.Caption = "IP = " + IPaddress2
End Function

Private Sub Form_Load()
Dim result As Boolean
' position the Web Browser control below the command button.
WebBrowser1.Move 0, 200
' navigate to a Web site for testing purposes.
WebBrowser1.Navigate "192.168.0.1/st_devic.html"
Do Until Not WebBrowser1.Busy And WebBrowser1.ReadyState = 4
DoEvents
Loop
result = RefreshPage()
End Sub
' Use this if you want to keep the program running and refresh the IP once
and hour
Private Sub Timer1_Timer()
Dim result As Boolean, testtime As Integer
testtime = Minute(Time)
If testtime = 0 Then
result = RefreshPage()
End If
If testtime = 25 Then
result = RefreshPage()
End If
End Sub

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.