Getting the Public IP address

Mark Wilcox m_p_wilcox at yahoo.co.uk
Thu Aug 8 10:54:23 EDT 2013



> I am trying to establish the User's public IP address. The Scripter's

> Scrapbook has several methods, all of which return the same result and all
> of which seem to return a local IP address (e.g. put the hostnametoaddress
> of the hostname into myIP). I am getting 192.168.2.2 (local) instead of the
> required 85.210.89.23 (public). It must be possible as a google search on
> 'My IP address' displays it.


You didn't say anything about what you want that IP address for. Make sure you do really want "the public IP address" as there are lots of situations where this concept isn't very useful. The IP address for the device that is running the app is almost certainly a local network address. In most homes the public IP address belongs to your router and your PC, Mac or mobile device knows nothing about it.

As such something like Mark's:
> put URL "http://qery.us/iptest.php"


Is the only sane way to go about getting your "public" address.

Note that in some scenarios there can also be a proxy at your company or ISP between you and the server at the other end, so this address may not even belong exclusively to you, it's just the address that a remote server needs to send packets back to for them to be routed to you.  In most situations, without explicit routes set up, there's no way for a remote computer to initiate contact with you. For example in some large corporate environments all traffic is routed through a central monitoring system, so this kind of web lookup results in an address that might not even be in the same country as you. Also, depending on the robustness of your required solution, you may not want to rely on a 3rd party service to return your address to you.


More information about the use-livecode mailing list