MartyConnelly
martyconnelly at shaw.ca
Fri Sep 17 15:25:57 CDT 2004
st_devic.html will probably only work for D-Link routers. Steve Conklin (Developer at UltraDNT) wrote: >Marty: >Most cool, the third one, going to dynip, did the job. > >The tracert didn't include mine, it just showed the ip's of my provider. >The second method, as written, didn't work. I assume its because my >router is not using 0.1 ... Routers cannot be counted on to use >192.168.0.1; some are 0.0, 100.1, 1.1, etc. (this early in the morning, >I forget what mine is, but I'll try it later.) Also, are these pages >"industry standard"? All router mfgr's use these (like st_devic.html)? >Anyway, if I used that, I'd need discovery code for the router first. > >Steve > > >-----Original Message----- >From: accessd-bounces at databaseadvisors.com >[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of MartyConnelly >Sent: Friday, September 17, 2004 1:46 AM >To: Access Developers discussion and problem solving >Subject: Re: [AccessD] External IP Address of Local Machine > > >I tried a couple of other methods > >grabbing the ip entries from this created text file ; sort of slow even >with only 3 hops >tracert -h 3 www.microsoft.com > testtrac.txt >---------------------------------------- >If you are configuring your router thru http methods >"http://192.168.0.1/st_devic.html" >is supposed to give you the ip address >but then you have to clear the cache >use this to clear out IE cached pages for DSL router app. > >Private Declare Function DeleteUrlCacheEntry Lib "wininet.dll" Alias > >"DeleteUrlCacheEntryA" (ByVal lpszUrlName As String) As Long > >DeleteUrlCacheEntry "http://192.168.0.1/st_devic.html" > >DeleteUrlCacheEntry "http://192.168.0.1/st_stats.html" >---------------- >http://checkip.dyndns.org/ >can only use every 10 minutes otherwise site gets annoyed > >Dim objExplorer As Object >Dim objDocument As Object >Dim strComputer As String >Dim objWMIService As Object >Dim colLoggedEvents As Object >Dim objEvent As Object >Dim dtmDate As Variant >Dim strReturn As String > >Set objExplorer = CreateObject("InternetExplorer.Application") >'Set objDocument = objExplorer.Document >objExplorer.Navigate "about:blank" >objExplorer.Toolbar = 0 >objExplorer.StatusBar = 0 >objExplorer.Width = 800 >objExplorer.Height = 570 >objExplorer.Left = 0 >objExplorer.Top = 0 >objExplorer.Visible = 1 > >objExplorer.Navigate "http://checkip.dyndns.org/" >Do While (objExplorer.Busy) >Loop >Dim webtx As String >Dim strHTML As String >'Set objDocument = objExplorer.Document >'objDocument.Open > >strHTML = objExplorer.Document.BODY.parentElement.outerHTML > Debug.Print strHTML >'parse the string here > >MsgBox "finished" >Set objExplorer = Nothing >Set objDocument = Nothing > >End Sub > > > >Steve Conklin (Developer at UltraDNT) wrote: > > > >>Marty: >>It iterated through about 6 times; most entries were blank, on about >>the 4th pass I got my DSN information, but it was also only showing the >> >> > > > >>LAN IP (192.168.x.x), not the WAN address. >> >>I found an external utility form the page Stuart suggested, it looks >>like I'll have to Shell that to know the user's external IP. The >>Help/About mentions MFC classes, so its making Windows calls that >>*should* be exposed somewhere as an API/DLL, but I haven't figured out >>how yet. >> >> >>Steve >> >> >>-----Original Message----- >>From: accessd-bounces at databaseadvisors.com >>[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of >>MartyConnelly >>Sent: Thursday, September 16, 2004 1:54 PM >>To: Access Developers discussion and problem solving >>Subject: Re: [AccessD] External IP Address of Local Machine >> >> >>I am just curious as to what this WMI code would return working >>through >> >>a router >>I get something like this without one. I have garbled numbers. >> >>DHCPEnabled: True >>DHCPLeaseExpires: 13/09/2004 5:42:44 AM >>DHCPLeaseObtained: 09/11/2004 5:42:50 AM >>DHCPServer: 64.58.156.40 >>DNSDomain: gv.homecable.net >>DNSHostName: MyComputer >>DomainDNSRegistrationEnabled: >>IPAddress: 24.344.56.566 >>IPAddresslen: 13 >>IPConnectionMetric: 30 >>IPEnabled: True >>MACAddress: 00:3B:27:43:6A:D1 >>MTU: >> >> >>Sub testnicconfigS() >>'set reference to WMI for WinXP and 2000 >>'The Win32_NetworkAdapterConfiguration WMI class represents 'the >>attributes and behaviors of a network adapter. 'This class has been >>extended to include extra properties and methods 'that support the >>management of the TCP/IP and Internetworking Packet Exchange >>(IPX) 'protocols (and are independent of the network adapter). Dim >>strComputer As String Dim objWMIService As Object Dim colitems As >>Object Dim objitem As Object On Error Resume Next 'there maybe multiple >> >> > > > >>Nic entries that are empty so skip them >> >>strComputer = "." 'default "." specifies local machine name Set >>objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") >>Set colitems = objWMIService.ExecQuery("Select * from >>Win32_NetworkAdapterConfiguration", , 48) >> >>For Each objitem In colitems >> >> Debug.Print "DHCPEnabled: " & objitem.DHCPEnabled >> Debug.Print "DHCPLeaseExpires: " & WMIDateStringToDate >>(objitem.DHCPLeaseExpires) >> Debug.Print "DHCPLeaseObtained: " & WMIDateStringToDate >>(objitem.DHCPLeaseObtained) >> Debug.Print "DHCPServer: " & objitem.DHCPServer >> Debug.Print "DNSDomain: " & objitem.DNSDomain >> >> Debug.Print "DNSHostName: " & objitem.DNSHostName >> >> Debug.Print "DomainDNSRegistrationEnabled: " & >>objitem.DomainDNSRegistrationEnabled >> >> Debug.Print "IPAddress: " & objitem.IPAddress(0) >> 'this is an array like other undocumented entries >> 'you will have to find by trial and error >> 'although there is an isarray property somewhere >> Debug.Print "IPAddresslen: " & Len(objitem.IPAddress(0)) >> Debug.Print "IPConnectionMetric: " & objitem.IPConnectionMetric >> Debug.Print "IPEnabled: " & objitem.IPEnabled >> Debug.Print "MACAddress: " & objitem.MACAddress >> Debug.Print "MTU: " & objitem.MTU >> >>Next >>End Sub >>Function WMIDateStringToDate(dtmInstallDate) As String 'WMI has an odd >>date format WMIDateStringToDate = CDate(Mid(dtmInstallDate, 5, 2) & "/" >> >> > > > >>& _ Mid(dtmInstallDate, 7, 2) & "/" & Left(dtmInstallDate, 4) _ & " " & >> >> > > > >>Mid(dtmInstallDate, 9, 2) & ":" & _ Mid(dtmInstallDate, 11, 2) & ":" & >>Mid(dtmInstallDate, _ 13, 2)) End Function >> >> >>Erwin Craps - IT Helps wrote: >> >> >> >> >> >>>Shields up is a test a webserver test, but just at the startpage >>>(before the test) you can see your dns name and ip address >>> >>>https://www.grc.com/x/ne.dll?bh0bkyd2 >>> >>> >>> >>> >>>-----Original Message----- >>>From: accessd-bounces at databaseadvisors.com >>>[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Steve >>>Conklin >>>(Developer at UltraDNT) >>>Sent: Thursday, September 16, 2004 4:17 PM >>>To: 'Access Developers discussion and problem solving' >>>Subject: RE: [AccessD] External IP Address of Local Machine >>> >>>Thanks, Stuart. >>> >>>-----Original Message----- >>>From: accessd-bounces at databaseadvisors.com >>>[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Stuart >>>McLachlan >>>Sent: Wednesday, September 15, 2004 7:48 PM >>>To: Access Developers discussion and problemsolving >>>Subject: Re: [AccessD] External IP Address of Local Machine >>> >>> >>>On 15 Sep 2004 at 18:55, Steve Conklin (Developer at UltraDNT) wrote: >>> >>> >>> >>> >>> >>> >>> >>>>I am using WDSI, WinInet and various API's to get 2 Access >>>>applications to send data to each other over FTP. It is working >>>> >>>> >well, > > >>>> >>>> >>>> >>>> >>>> >>>> >>> >>> >>> >>> >>>>but I want the server to be secure, that is to only allow >>>>logins/files >>>> >>>> >>>> >>>> >>>> >>>> >>> >>> >>> >>> >>>>to come from specific IP's. This is ok when I am sending, because I >>>>know my IP, and I tell the client to allow my IP. When I (hopefully) >>>> >>>> > > > >>>>sell a copy to the client's client, how can they easily determine >>>> >>>> >>>> >>>> >>>> >>>> >>>their IP? >>> >>> >>> >>> >>> >>> >>>>I have looked at the Winsock API and can get remote IP's via Host >>>> >>>> >>>> >>>> >>>> >>>> >>>Name. >>> >>> >>> >>> >>> >>> >>>>However, when I want to get the IP of the local PC, it returns the >>>>192.168.x.x address; how can I get the external IP that the FTP >>>> >>>> >server > > >>>> >>>> >>>> >>>> >>>> >>>> >>> >>> >>> >>> >>>>needs to know through VB/API? >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>If you are working through a router, you can't since only the router >>>knows >>>the external address.. The only way would be to bounce an HTML >>> >>> >>> >>> >>request >> >> >> >> >>>of >>>an external website and read the return data. There a numbder of >>>freeware tools available on the web that do just that. See >>>http://www.snapfiles.com/freeware/network/fwip.html for examples >>> >>> >>>If you're machine is directly connected to the Internet, you can >>>iterate >>> >>>through it's IP adddresses. >>> >>>Here's a module to do it (watch for linewrap) >>> >>>Option Compare Database >>>Option Explicit >>> >>>Const MAX_IP = 5 'To make a buffer... i dont think you have more >>> >>> >than > > >>>5 ip on your pc.. >>> >>>Type IPINFO >>> dwAddr As Long ' IP address >>> dwIndex As Long ' interface index >>> dwMask As Long ' subnet mask >>> dwBCastAddr As Long ' broadcast address >>> dwReasmSize As Long ' assembly size >>> unused1 As Integer ' not currently used >>> unused2 As Integer '; not currently used End Type >>> >>>Type MIB_IPADDRTABLE >>> dEntrys As Long 'number of entries in the table >>> mIPInfo(MAX_IP) As IPINFO 'array of IP address entries End Type >>> >>>Type IP_Array >>> mBuffer As MIB_IPADDRTABLE >>> BufferLen As Long >>>End Type >>> >>>Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" >>>(Destination As Any, Source As Any, ByVal Length As Long) Public >>>Declare Function GetIpAddrTable Lib "IPHlpApi" (pIPAdrTable As Byte, >>>pdwSize As Long, ByVal Sort As Long) As Long >>> >>> >>>Public Function ConvertAddressToString(longAddr As Long) As String >>> Dim myByte(3) As Byte >>> Dim Cnt As Long >>> CopyMemory myByte(0), longAddr, 4 >>> For Cnt = 0 To 3 >>> ConvertAddressToString = ConvertAddressToString + >>>CStr(myByte(Cnt)) + "." >>> Next Cnt >>> ConvertAddressToString = Left$(ConvertAddressToString, >>>Len(ConvertAddressToString) - 1) End Function >>> >>>Public Function IPAddresses() As Long >>>Dim lngRetVal As Long >>>Dim lngLoop As Long >>>Dim bBytes() As Byte >>>Dim IPList As MIB_IPADDRTABLE >>> >>> GetIpAddrTable ByVal 0&, lngRetVal, True >>> >>> If lngRetVal <= 0 Then Exit Function >>> ReDim bBytes(0 To lngRetVal - 1) As Byte >>> 'retrieve the data >>> GetIpAddrTable bBytes(0), lngRetVal, False >>> >>> 'Get the first 4 bytes to get the entry's.. ip installed >>> CopyMemory IPList.dEntrys, bBytes(0), 4 >>> >>> For lngLoop = 0 To IPList.dEntrys - 1 >>> 'Copy whole structure to Listing.. >>> CopyMemory IPList.mIPInfo(lngLoop), bBytes(4 + (lngLoop * >>>Len(IPList.mIPInfo(0)))), Len(IPList.mIPInfo(lngLoop)) >>> Debug.Print "IP address : " & >>>ConvertAddressToString(IPList.mIPInfo(lngLoop).dwAddr) >>> Debug.Print "IP Subnetmask : " & >>>ConvertAddressToString(IPList.mIPInfo(lngLoop).dwMask) >>> Debug.Print "BroadCast IP address : " & >>>ConvertAddressToString(IPList.mIPInfo(lngLoop).dwBCastAddr) >>> Debug.Print "**************************************" >>> Next >>> >>>End Function >>> >>> >>>-- >>>Stuart >>> >>> >>> >>> >>> >>> >>> >>> >> >> >> >> > > > -- Marty Connelly Victoria, B.C. Canada