Can VB retrieve my dynamic IP from my Linksys router?  | |
November 14th, 2003, 05:21 PM
|
#1 (permalink)
| | Member
Join Date: Oct 2003 Location: In the middle....
Posts: 161
| Can VB retrieve my dynamic IP from my Linksys router?
I have a DSL modem > Linksys router > PC. What I think I want to do (feel free to suggest alternatives) is write a VB program to retrieve my dynamic IP address (WAN), (which my ISP feels the need to change every couple of days), then email it in a text file or something equivalent. I have (some) experience writing VB code, but I'm not advanced by any means.
Maybe there's some software available to grab the IP?
I remote in to my home PC from work occaisionally and of course I can't when the IP has changed without trying 255 different IP addresses (The first three sets are always the same, e.g. xxx.xxx.xxx.1-255).
Thanks for any ideas,
-Dave- |
| |
November 14th, 2003, 05:30 PM
|
#2 (permalink)
| | Ultimate Member
Join Date: Oct 2001 Location: Queen Creek, AZ
Posts: 1,480
|
__________________
Never argue with a computer, without a hammer.
Never program and drink beer at the same time.
Never trust a programmer who carries a screwdriver.
|
| |
November 14th, 2003, 05:49 PM
|
#3 (permalink)
| | Not Really a Member
Join Date: Oct 2001
Posts: 25,382
|
If you want to do it just as a project to give it a shot...
what you could do is maybe make a HTTP request to www.whatismyip.com and parse through the response for your IP.
Az's response is by far the easiest and most common method 
__________________
Helicopters don't fly; they vibrate so much and make so much noise that the earth rejects them.
|
| |
November 25th, 2003, 04:23 PM
|
#4 (permalink)
| | Member
Join Date: Oct 2003
Posts: 263
|
I dont know how well you know vb but here goes...
Open or start a new project
->Project
-->Components
->go down to Microsoft Winsock ver. bla bla (check that off and hit ok)
->Put the tool from the tool menu on the form.
The code on the form is as follows:
Private Sub Form_Load()
Dim strIP As String
strIP = Winsock1.LocalIP
End Sub
Basically all you are doing is throwing your ip address into a variable called strIP...if you have any questions post back or e-mail me |
| |
December 2nd, 2003, 08:04 PM
|
#5 (permalink)
| | Not Really a Member
Join Date: Oct 2001
Posts: 25,382
|
amtrac, you forgot he needs to get his routable IP.. not the local IP
His local machine will have a 192.168.1.x IP which is useless out on the internet. He needs to know the IP his ISP gives him. |
| |
December 2nd, 2003, 10:10 PM
|
#6 (permalink)
| | Member
Join Date: Sep 2002
Posts: 364
|
I tried it. It doesn't return my IP for my LAN. I got a 169.xxx.xxx.xxx so I assume its my routers IP or something. |
| |
December 2nd, 2003, 11:17 PM
|
#7 (permalink)
| | Member
Join Date: Oct 2003 Location: In the middle....
Posts: 161
|
I'm not sure what you're actually after Creosote but here's the solution I ended up with which retrieves my WAN IP and then emails it to my Hotmail account thru Oulook Express. I then run it everyday in scheduled task.
----------------------------------------------------
Public My_IP As String
Public MY_date As Date
Private Sub Send_My_IP()
Dim b1 As Boolean
Call MessageCall
b1 = False
MAPISession1.SignOn
MAPISession1.DownLoadMail = False
With MAPIMessages1
.SessionID = MAPISession1.SessionID
.Compose
.RecipAddress = "Smee@hotmail.com"
.AddressResolveUI = True
.ResolveName
.MsgSubject = "Home IP at " & Time & " on " & Date
.MsgNoteText = "My home IP is " & My_IP & " on " & Date
.Send False
End With
MAPISession1.SignOff
End Sub
Private Sub Form_Load()
Call Send_My_IP
End
End Sub
Sub MessageCall()
MY_date = Date + Time
My_IP = MessageLoad("www.showmyip.com/simple/")
End Sub
Function MessageLoad(URL As String) As String
Dim IEApp As Object
Dim IEDocument As Object
Dim i As Long
Set IEApp = CreateObject("InternetExplorer.Application")
IEApp.Visible = False
IEApp.Navigate URL
Do: Loop Until IEApp.Busy = False
Set IEDocument = IEApp.Document
MessageLoad = IEDocument.Body.innerText
IEApp.Quit
Set IEDocument = Nothing
Set IEApp = Nothing
End Function
--------------------------------------------------------
Outlook Express has to be setup to not prompt you for sending mail.
-Dave- |
| |
December 3rd, 2003, 12:20 AM
|
#8 (permalink)
| | Member
Join Date: Sep 2002
Posts: 364
|
I was saying I tried amtrac24's solution and it's not giving me my local LAN address.
Your solution looks cool. Here is another solution to send the email with CDO if you want to try that too. http://support.microsoft.com/?id=286431 |
| |
December 3rd, 2003, 07:29 PM
|
#9 (permalink)
| | Not Really a Member
Join Date: Oct 2001
Posts: 25,382
|
169.254.x.x is a BS IP MS gives to a network card that is set to DHCP but can't reach a DHCP server.
Chances are you got the IP of a network interface with no IP.
(there's about 10 on any given win2k/XP machine  stupid WAN interfaces that it hides from the user) |
| | | Thread Tools | Search this Thread | | | | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |