Jump to content
Sign in to follow this  
yucatan

IP addres

Recommended Posts

Hi i'm looking for a way to detect my IP adress here a sample of what i meen i need the extrern ip not the intern ip

something like this. that i the internet ip adres have in a $var

post-33750-1209334471_thumb.jpg

Edited by yucatan

Share this post


Link to post
Share on other sites

Wrote this some time ago:

#include <INet.au3>
Dim $ip
$data=_INetGetSource("http://whatsmyip.net/")
$data=StringTrimLeft($data,StringInStr($data,"""readonly"">")+10)
$data=StringLeft($data,StringInStr($data,"<")-1)
$ip=$data
Edited by monoceres

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Tons of ways to skin this cat:

Func _RetrieveIP($file = "")
    local $ip, $tempfile = @TempDir & "\ip.txt"
    If $file = "" Then
        InetGet("http://whatismyip.com/automation/n09230945.asp",  $tempfile)
        If @Error Then
            return 0
        Else
            $ip = FileRead($tempfile)
            return $ip
        EndIf
    ElseIf $file <> "" Then
        InetGet("http://whatismyip.com/automation/n09230945.asp",  $tempfile)
    If @error Then
            return 0
        Else
            FileMove($tempfile, $file)
        EndIf
    EndIf
    FileDelete($tempfile)
EndFuncoÝ÷ Ù8^ëjëh×6MsgBox(0, "Test", _RetrieveIP())

Share this post


Link to post
Share on other sites

_GetIP() does not get your external Ip address though It will only return your private IP example 192.168.1.1


" I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln

Share this post


Link to post
Share on other sites

_GetIP() does not get your external Ip address though It will only return your private IP example 192.168.1.1

Are you sure about that?

It works for me.

The help file states:

Get public IP address of a network/computer.

Try this code from the help file:

#include <Inet.au3>
$PublicIP = _GetIP()
MsgBox(0, "IP Address", "Your IP Address is: " & $PublicIP)

Maybe you are think about the @IPAddress1 macro which returns:

IP address of first network adapter. Tends to return 127.0.0.1 on some computers.

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Story checks out

GetIP() gets the Public IP for me.

Are you sure about that?

It works for me.

The help file states:

Get public IP address of a network/computer.

Try this code from the help file:

#include <Inet.au3>
$PublicIP = _GetIP()
MsgBox(0, "IP Address", "Your IP Address is: " & $PublicIP)

Share this post


Link to post
Share on other sites

Thats weird last time I used it it gave me the local static IP address.... Which was not my public address.... Good to know it is not now..


" I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln

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  

×
×
  • Create New...