Sign in to follow this  
Followers 0
Rad

How to find your real IP?

9 posts in this topic

Explained in the title, not sure how I would determine the IP...

Is there a way to read it from your lan driver or whatever? Not really sure. I also thought about trying to search for your IP from a webpage (ex: www.getip.com) but havent tried that (might be an easier way)

I searched but it gives me an error :whistle: - I think because IP is to short or maybe it just returned to many results...

Maybe theres even a registry key that stores your IP? But then again I probrably couldnt find that either

Share this post


Link to post
Share on other sites



Explained in the title, not sure how I would determine the IP...

Is there a way to read it from your lan driver or whatever? Not really sure. I also thought about trying to search for your IP from a webpage (ex: www.getip.com) but havent tried that (might be an easier way)

I searched but it gives me an error :whistle: - I think because IP is to short or maybe it just returned to many results...

Maybe theres even a registry key that stores your IP? But then again I probrably couldnt find that either

Take a look at this and see if it will work for you.

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks that helped alot =)

also thanks to JSThePatriot for his code, i fixed it a bit... his must have been outdated

If URLDownloadToFile("http://www.whatismyip.com",@tempdir & "\~ip.tmp") Then
     $IP = FileRead(@tempdir & "\~ip.tmp",FileGetSize(@tempdir & "\~ip.tmp"))
     FileDelete(@tempdir & "\~ip.tmp")
     $IP = StringTrimLeft($IP,StringInStr($IP,"<TITLE>WhatIsMyIP.com - ")+stringlen("<TITLE>WhatIsMyIP.com - ")-1)
     $IP = StringLeft($IP,StringInStr($IP,"</TITLE>")-1)
     msgbox(0,"",'"' & $IP & '"')
     Return $ip
  Else
     SetError(1)
     Return -1
  EndIf

Edit~I was just adding this to my UDF under the name _GetIP... and it highlighted it as a func as I wrote it...

There was a func already lol =)

Edited by Rad

Share this post


Link to post
Share on other sites

Thanks that helped alot =)

also thanks to JSThePatriot for his code, i fixed it a bit... his must have been outdated

If URLDownloadToFile("http://www.whatismyip.com",@tempdir & "\~ip.tmp") Then
     $IP = FileRead(@tempdir & "\~ip.tmp",FileGetSize(@tempdir & "\~ip.tmp"))
     FileDelete(@tempdir & "\~ip.tmp")
     $IP = StringTrimLeft($IP,StringInStr($IP,"<TITLE>WhatIsMyIP.com - ")+stringlen("<TITLE>WhatIsMyIP.com - ")-1)
     $IP = StringLeft($IP,StringInStr($IP,"</TITLE>")-1)
     msgbox(0,"",'"' & $IP & '"')
     Return $ip
  Else
     SetError(1)
     Return -1
  EndIf

Edit~I was just adding this to my UDF under the name _GetIP... and it highlighted it as a func as I wrote it...

There was a func already lol =)

Yes, it's in the Inet.au3 include.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

There was a func already lol =)

_GetIP gets local ip i think, but i guess you know that right. Edited by Cue

Share this post


Link to post
Share on other sites

_GetIP() gets your global ip.


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

_GetIP unfortunately relies on external websites to return your IP... is there not a more reliable method for retrieving this info?

The function is already half out-dated. It first checks checkip.dyndns.org which still works, but has a "fail safe" and also checks whatismyip.com, which now fails (its close... it returns your ip with </h1> tagged to the end).

But we can see that it relies on a) the website being available and :whistle: the website not changing.

This isn't a good long-term solution.

- LD

Edited by LondonNDIB

Share this post


Link to post
Share on other sites

But in an effort to make it a little more long-term... here is a replacement for the _GetIP.au3 UDF which fixes the problem with the 2nd check and adds two more checks just in case. They are a little slower, but are only checked if the first 2 fail.

;===============================================================================
;
; Function Name:    _GetIP()
; Description:    Get public IP address of a network/computer.
; Parameter(s):  None
; Requirement(s):   Internet access.
; Return Value(s):  On Success - Returns the public IP Address
;                  On Failure - -1  and sets @ERROR = 1
; Author(s):        Larry/Ezzetabi & Jarvis Stubblefield
;
;===============================================================================
Func _GetIP()
    Local $ip, $t_ip
    If InetGet("http://checkip.dyndns.org/?rnd1=" & Random(1, 65536) & "&rnd2=" & Random(1, 65536), @TempDir & "\~ip.tmp") Then
        $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp"))
        FileDelete(@TempDir & "\~ip.tmp")
        $ip = StringTrimLeft($ip, StringInStr($ip, "Current IP Address:") + 19)
        $ip = StringLeft($ip, StringInStr($ip, "<") - 1)
        $t_ip = StringSplit($ip, '.')
        If $t_ip[0] = 4 And StringIsDigit($t_ip[1]) And StringIsDigit($t_ip[2]) And StringIsDigit($t_ip[3]) And StringIsDigit($t_ip[4]) Then
            Return $ip
        EndIf
    EndIf
    If InetGet("http://www.whatismyip.com/?rnd1=" & Random(1, 65536) & "&rnd2=" & Random(1, 65536), @TempDir & "\~ip.tmp") Then
        $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp"))
        FileDelete(@TempDir & "\~ip.tmp")
        $ip = StringTrimLeft($ip, StringInStr($ip, "<TITLE>WhatIsMyIP.com - ") + 23)
        $ip = StringLeft($ip, StringInStr($ip, "<") - 1)
        $ip = StringStripWS($ip, 8)
        $t_ip = StringSplit($ip, '.')
        If $t_ip[0] = 4 And StringIsDigit($t_ip[1]) And StringIsDigit($t_ip[2]) And StringIsDigit($t_ip[3]) And StringIsDigit($t_ip[4]) Then
            Return $ip
        EndIf
    EndIf
    If InetGet("http://www.ip-adress.com/", @TempDir & "\~ip.tmp") Then
        $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp"))
        FileDelete(@TempDir & "\~ip.tmp")
        $ip = StringTrimLeft($ip, StringInStr($ip, "My IP Address: ") + 14)
        $ip = StringLeft($ip, StringInStr($ip, @TAB) - 1)
        $ip = StringStripWS($ip, 8)
        $t_ip = StringSplit($ip, '.')
        If $t_ip[0] = 4 And StringIsDigit($t_ip[1]) And StringIsDigit($t_ip[2]) And StringIsDigit($t_ip[3]) And StringIsDigit($t_ip[4]) Then
            Return $ip
        EndIf
    EndIf
    If InetGet("http://whatismyipaddress.com/?rnd1=" & Random(1, 65536) & "&rnd2=" & Random(1, 65536), @TempDir & "\~ip.tmp") Then
        $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp"))
        FileDelete(@TempDir & "\~ip.tmp")
        $ip = StringTrimLeft($ip, StringInStr($ip, "Your IP address is ") + 18)
        $ip = StringLeft($ip, StringInStr($ip, "<") - 1)
        $ip = StringStripWS($ip, 8)
        $t_ip = StringSplit($ip, '.')
        If $t_ip[0] = 4 And StringIsDigit($t_ip[1]) And StringIsDigit($t_ip[2]) And StringIsDigit($t_ip[3]) And StringIsDigit($t_ip[4]) Then
            Return $ip
        EndIf
    EndIf
    SetError(1)
    Return -1
EndFunc  ;==>_GetIP

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0