Jump to content

Get external IP of each adapter


afliw
 Share

Go to solution Solved by Gianni,

Recommended Posts

Hello everyone!

I've been searching and still can't find an answer to do this.

Scenario:

I've three networks adapters, each with a different connection to internet (each with a different external [public] IP).

Target:

Get each external IP for every adapter.

 

I can get each external IP running _GetIP()  from <Inet.au3> several times, but they're returned randomly. I have to know which adapter has each IP.

Ideas?

Thanks in advanced.

Regards!

Link to comment
Share on other sites

just a wild guess
you could disable all 3 cards
then enable one at a time and getip() for each
at end reenable all 3 cards

this 2 links could be of interest

>link1

>link2

>this is interesting too

good luck

edit:

remembered just now >also this link

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Thanks for the answer Chimp.

Disabling and re-enabling the adapters is not acceptable for me. Just feel uncomfortable and one of the lines is a PPPoE, and dynamic address, so each team I disable, it's gonna get a different IP.

The STUN protocol looks interesting, but seems like a bit too much for such a simple task, and it doesn't let me chose the adapter to query.

The last link you gave it's useful for another task I have in mind, so, thanks again for that. =)

I've found a workaround although, using an external application named cURL, that with a simple CMD line I can get what I wanted.

Yet again, thank you very much for your help!

Best regards!

Link to comment
Share on other sites

...

 

I've found a workaround although, using an external application named cURL, that with a simple CMD line I can get what I wanted.

...

 

ok, good,

....it sounds interesting, could you show that cmd line?

thanks

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

ok, good,

....it sounds interesting, could you show that cmd line?

thanks

 

Sure.

I downloaded cURL's bin form this website: http://www.confusedbycode.com/curl/

And the CMD line I'm using is like this: 

curl -P 192.168.15.107 ifconfig.me/ip

OR

curl --interface 192.168.15.107 ifconfig.me/ip

Where ifconfig.me/ip is a service that returns only a string with your external IP. [You have other data you can get from that site (see http://ifconfig.me on browser for more), and other servers that offers similar services.]

192.168.15.107 is the local IP address of the adapter I want to get the external IP.

Those two flags (--interface and -P) do the same thing, indicate cURL trough which adapter you want to make the query from.

 

So the rest is easy, inlcude cURL on your script folder, do a Run() on AutoIt, get the stdout, and show on a floating window or something. ^^

Hope it helps somebody looking for the same.

Thanks again!

Link to comment
Share on other sites

  • Solution

thank you afliw, got it

MsgBox(0, "External IP", "the extarnal IP of the card with IP address " & @IPAddress1 & " is " & _GetExternalIP(@IPAddress1))

Func _GetExternalIP($sCard)
    Local $sOutput, $hPid = Run("CURL.EXE --interface " & $sCard & " ifconfig.me/ip", "", @SW_HIDE, 2)
    Do
        $sOutput &= StdoutRead($hPid)
    Until @error
    Return ($sOutput)
EndFunc   ;==>_GetExternalIP

bye

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...