Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: hunter18 en 23 Agosto 2010, 06:58 am



Título: Saber ip de conexion a internet de mi computador
Publicado por: hunter18 en 23 Agosto 2010, 06:58 am
He buscado y solo encuentro ejemplos donde me dan la ip de la red local por ejemplo el 192.168.1.35 y yo quiero saber la ip con la que me conecto a internet las que salen p.e 190.232.8.41 igual a como lo hace http://midireccionip.com/


Título: Re: Saber ip de conexion a internet de mi computador
Publicado por: andreselmejor en 23 Agosto 2010, 07:21 am
-Que tal si abres conexiones de red--->estado---->soporte---->detalles y listo.

-Otra forma es con el ares : panel de control---->red y listo tu ip publica.

-cmd---->ipconfig y listo.(si tienes el modem conectado directo)

-En el router,tambien sale. :silbar:


 Suerte.



Título: Re: Saber ip de conexion a internet de mi computador
Publicado por: BlackZeroX en 23 Agosto 2010, 07:31 am
.
Esto ya esta en el foro, usa el buscador y lo encontraras!ˇ.

Nota: Hay como dos codigos que doy fe de la existencia en este foro asi que a buscarle!ˇ.

Dulces Lunas!ˇ.


Título: Re: Saber ip de conexion a internet de mi computador
Publicado por: Petro_Boca en 23 Agosto 2010, 12:08 pm
http://galaxiagamer.esforos.com/tutorial-visor-de-tu-ip-t1563


Título: Re: Saber ip de conexion a internet de mi computador
Publicado por: hunter18 en 23 Agosto 2010, 20:08 pm
Sigo sin solucionar, siempre obtengo, me parece que se llama direccion privada(interna) el tipico 192.168.1.39,192.168.1.40, etc la misma que tambien sale con ipconfig ya que estoy en una red local y no directo al router.

Si utilizo un control Winsock1.LocalIP tambien me devuelve la ip privada y yo quiero obtener desde vb6.0 la ip publica(externa), como lo hace la mentada http://midireccionip.com/ (http://midireccionip.com/) pero desde vb

saludos


Título: Re: Saber ip de conexion a internet de mi computador
Publicado por: xkiz ™ en 23 Agosto 2010, 20:11 pm
asi sacas la Ip Publica:

Código
  1. Const INTERNET_OPEN_TYPE_DIRECT = 1
  2. Const INTERNET_OPEN_TYPE_PROXY = 3
  3. Const INTERNET_FLAG_RELOAD = &H80000000
  4. Const sURL = "http://checkip.dyndns.org/"
  5.  
  6. Private Declare Function InternetOpen Lib "wininet" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
  7. Private Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As Long) As Integer
  8. Private Declare Function InternetReadFile Lib "wininet" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
  9. Private Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
  10.  
  11. Public Function GetPublicIp()
  12. Dim pIP() As String
  13. Dim nose As String
  14.    Dim hOpen As Long, hFile As Long, sBuffer As String, Ret As Long
  15.    sBuffer = Space(1000)
  16.    hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
  17.    hFile = InternetOpenUrl(hOpen, sURL, vbNullString, ByVal 0&, INTERNET_FLAG_RELOAD, ByVal 0&)
  18.    InternetReadFile hFile, sBuffer, 1000, Ret
  19.  
  20.    InternetCloseHandle hFile
  21.    InternetCloseHandle hOpen
  22.  
  23.    pIP = Split(Trim(sBuffer), ": ")
  24.    nose = Left(pIP(1), Len(pIP(1)) - 16)
  25.    GetPublicIp = nose
  26. End Function
  27.  
  28. Private Sub Main()
  29. Debug.Print GetPublicIp
  30. End Sub
  31.  
  32.  


Título: Re: Saber ip de conexion a internet de mi computador
Publicado por: hunter18 en 23 Agosto 2010, 20:32 pm
Te pasaste con el codigo, gracias

 ;D


Título: Re: Saber ip de conexion a internet de mi computador
Publicado por: BlackZeroX en 23 Agosto 2010, 20:42 pm
http://galaxiagamer.esforos.com/tutorial-visor-de-tu-ip-t1563

Eso no sirve para lo que se requiere (en Modems-Router) ¬¬".

Ducles Lunas!ˇ.


Título: Re: Saber ip de conexion a internet de mi computador
Publicado por: _katze_ en 23 Agosto 2010, 20:48 pm
Código
  1. Const INTERNET_OPEN_TYPE_DIRECT = 1
  2. Const INTERNET_OPEN_TYPE_PROXY = 3
  3. Const INTERNET_FLAG_RELOAD = &H80000000
  4. Const sURL = "http://checkip.dyndns.org/"
  5.  
  6. Private Declare Function InternetOpen Lib "wininet" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
  7. Private Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As Long) As Integer
  8. Private Declare Function InternetReadFile Lib "wininet" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
  9. Private Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
  10.  
  11. Public Function GetPublicIp()
  12. Dim pIP() As String
  13. Dim nose As String
  14.    Dim hOpen As Long, hFile As Long, sBuffer As String, Ret As Long
  15.    sBuffer = Space(108)
  16.    hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
  17.    hFile = InternetOpenUrl(hOpen, sURL, vbNullString, ByVal 0&, INTERNET_FLAG_RELOAD, ByVal 0&)
  18.    InternetReadFile hFile, sBuffer, [color=limegreen]108[/color], Ret
  19.  
  20.    InternetCloseHandle hFile
  21.    InternetCloseHandle hOpen
  22.  
  23.    pIP = Split(Trim(sBuffer), ": ")
  24.    nose = Left(pIP(1), Len(pIP(1)) - 16)
  25.    GetPublicIp = nose
  26. End Function
  27.  
  28. Private Sub Main()
  29. Debug.Print GetPublicIp
  30. End Sub
  31.  
  32.  

modificando el buffer a como esta y lo q esta en verde ! tmb funcio esto es valido tmb o hay algo en especial el valor que se asigno en tu code original xkiz?
muy bueno y bien practico ::) ::) ::)


Título: Re: Saber ip de conexion a internet de mi computador
Publicado por: xkiz ™ en 23 Agosto 2010, 23:03 pm
lo del size del buffer?

no se por que estaba en 1000, es un codigo viejo ese, nunca le preste mucha atencion. osea tengo el mismo codigo en C++ y ahi el size del buffer esta en 110, creo que aca le habia puesto 1000, para estar seguro, por si los de DynDNS modificaban algo en el .php ese. pero con 110 ó 108 tendria que ir bien.



Título: Re: Saber ip de conexion a internet de mi computador
Publicado por: Petro_Boca en 24 Agosto 2010, 03:39 am
Código
  1. Const INTERNET_OPEN_TYPE_DIRECT = 1
  2. Const INTERNET_OPEN_TYPE_PROXY = 3
  3. Const INTERNET_FLAG_RELOAD = &H80000000
  4. Const sURL = "http://checkip.dyndns.org/"
  5.  
  6. Private Declare Function InternetOpen Lib "wininet" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
  7. Private Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As Long) As Integer
  8. Private Declare Function InternetReadFile Lib "wininet" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
  9. Private Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
  10.  
  11. Public Function GetPublicIp()
  12. Dim pIP() As String
  13. Dim nose As String
  14.    Dim hOpen As Long, hFile As Long, sBuffer As String, Ret As Long
  15.    sBuffer = Space(108)
  16.    hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
  17.    hFile = InternetOpenUrl(hOpen, sURL, vbNullString, ByVal 0&, INTERNET_FLAG_RELOAD, ByVal 0&)
  18.    InternetReadFile hFile, sBuffer, 108, Ret
  19.  
  20.    InternetCloseHandle hFile
  21.    InternetCloseHandle hOpen
  22.  
  23.    pIP = Split(Trim(sBuffer), ": ")
  24.    nose = Left(pIP(1), Len(pIP(1)) - 16)
  25.    GetPublicIp = nose
  26. End Function
  27.  
  28. Private Sub Main()
  29. Debug.Print GetPublicIp
  30. End Sub
  31.  
  32.  

modificando el buffer a como esta y lo q esta en verde ! tmb funcio esto es valido tmb o hay algo en especial el valor que se asigno en tu code original xkiz?
muy bueno y bien practico ::) ::) ::)

asi :D

pone 1 boton

Código
  1. Const INTERNET_OPEN_TYPE_DIRECT = 1
  2. Const INTERNET_OPEN_TYPE_PROXY = 3
  3. Const INTERNET_FLAG_RELOAD = &H80000000
  4. Const sURL = "http://checkip.dyndns.org/"
  5.  
  6. Private Declare Function InternetOpen Lib "wininet" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
  7. Private Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As Long) As Integer
  8. Private Declare Function InternetReadFile Lib "wininet" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
  9. Private Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
  10.  
  11. Public Function GetPublicIp()
  12. Dim pIP() As String
  13. Dim nose As String
  14.    Dim hOpen As Long, hFile As Long, sBuffer As String, Ret As Long
  15.    sBuffer = Space(108)
  16.    hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
  17.    hFile = InternetOpenUrl(hOpen, sURL, vbNullString, ByVal 0&, INTERNET_FLAG_RELOAD, ByVal 0&)
  18.    InternetReadFile hFile, sBuffer, 108, Ret
  19.  
  20.    InternetCloseHandle hFile
  21.    InternetCloseHandle hOpen
  22.  
  23.    pIP = Split(Trim(sBuffer), ": ")
  24.    nose = Left(pIP(1), Len(pIP(1)) - 16)
  25.    GetPublicIp = nose
  26. End Function
  27.  
  28.  
  29.  
  30.  
  31. Private Sub Command1_Click()
  32. MsgBox GetPublicIp
  33. End Sub
  34.  
  35.  


Título: Re: Saber ip de conexion a internet de mi computador
Publicado por: _katze_ en 24 Agosto 2010, 03:41 am
con minimo 108 anda bien xkiz asi no c ocupa mas del sizebuffer ! pero por las dudas hay como esta esta bn ! gracias por responder


Título: Re: Saber ip de conexion a internet de mi computador
Publicado por: Petro_Boca en 24 Agosto 2010, 03:43 am
con minimo 108 anda bien xkiz asi no c ocupa mas del sizebuffer ! pero por las dudas hay como esta esta bn ! gracias por responder

fijate q modifique mi mensaje...

Código
  1. Const INTERNET_OPEN_TYPE_DIRECT = 1
  2. Const INTERNET_OPEN_TYPE_PROXY = 3
  3. Const INTERNET_FLAG_RELOAD = &H80000000
  4. Const sURL = "http://checkip.dyndns.org/"
  5.  
  6. Private Declare Function InternetOpen Lib "wininet" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
  7. Private Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As Long) As Integer
  8. Private Declare Function InternetReadFile Lib "wininet" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
  9. Private Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
  10.  
  11. Public Function GetPublicIp()
  12. Dim pIP() As String
  13. Dim nose As String
  14.    Dim hOpen As Long, hFile As Long, sBuffer As String, Ret As Long
  15.    sBuffer = Space(108)
  16.    hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
  17.    hFile = InternetOpenUrl(hOpen, sURL, vbNullString, ByVal 0&, INTERNET_FLAG_RELOAD, ByVal 0&)
  18.    InternetReadFile hFile, sBuffer, 108, Ret
  19.  
  20.    InternetCloseHandle hFile
  21.    InternetCloseHandle hOpen
  22.  
  23.    pIP = Split(Trim(sBuffer), ": ")
  24.    nose = Left(pIP(1), Len(pIP(1)) - 16)
  25.    GetPublicIp = nose
  26. End Function
  27.  
  28. Private Sub Main()
  29. Debug.Print GetPublicIp
  30. End Sub
  31.  
  32.  

modificando el buffer a como esta y lo q esta en verde ! tmb funcio esto es valido tmb o hay algo en especial el valor que se asigno en tu code original xkiz?
muy bueno y bien practico ::) ::) ::)

asi :D

pone 1 boton

Código
  1. Const INTERNET_OPEN_TYPE_DIRECT = 1
  2. Const INTERNET_OPEN_TYPE_PROXY = 3
  3. Const INTERNET_FLAG_RELOAD = &H80000000
  4. Const sURL = "http://checkip.dyndns.org/"
  5.  
  6. Private Declare Function InternetOpen Lib "wininet" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
  7. Private Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As Long) As Integer
  8. Private Declare Function InternetReadFile Lib "wininet" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
  9. Private Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
  10.  
  11. Public Function GetPublicIp()
  12. Dim pIP() As String
  13. Dim nose As String
  14.    Dim hOpen As Long, hFile As Long, sBuffer As String, Ret As Long
  15.    sBuffer = Space(108)
  16.    hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
  17.    hFile = InternetOpenUrl(hOpen, sURL, vbNullString, ByVal 0&, INTERNET_FLAG_RELOAD, ByVal 0&)
  18.    InternetReadFile hFile, sBuffer, 108, Ret
  19.  
  20.    InternetCloseHandle hFile
  21.    InternetCloseHandle hOpen
  22.  
  23.    pIP = Split(Trim(sBuffer), ": ")
  24.    nose = Left(pIP(1), Len(pIP(1)) - 16)
  25.    GetPublicIp = nose
  26. End Function
  27.  
  28.  
  29.  
  30.  
  31. Private Sub Command1_Click()
  32. MsgBox GetPublicIp
  33. End Sub
  34.  
  35.  


Título: Re: Saber ip de conexion a internet de mi computador
Publicado por: _katze_ en 24 Agosto 2010, 03:54 am
no dije como usarlo man, pero gracias igual !solo acote lo del code!