Public ip address

Roger Amar Roger at
Sun Jul 25 14:15:37 CDT 2004

Hello Alex,

We have to maintain a radio stations network running our automation software,MacBroadcast*, via Timbuktu. To take the control of a distant computer, PC or Macintosh, we have to know the public IP address to connect to that computer and do our job. Since the IP address provided by the ISP is not permanent, I want to write a simple code which once an hour, is able to send us the actual IP public address of every radio station. (Some of them have a fixed IP Address which never change but the cost of this solution is about 20 $ per month.)
Using solutions like DynDNS which is supposed to translate the IP address to a fixed one is not a secure solution.
I want to do what is able to do.
The solutions suggested by this list are just able to return the lan ip address.

Thanks to all of you for your replies


* and then click on "MacBroadcast"
-----Message d'origine-----
De : use-revolution-bounces at [mailto:use-revolution-bounces at] De la part de Alex Tweedly
Envoyé : dimanche 25 juillet 2004 03:22
À : How to use Revolution
Objet : Re: Public ip address

At 02:37 25/07/2004 +0200, Pierre Sahores wrote:

>Seems OK there, at least from within the messagebox (Rev 2.1.2 / 2.2.1 
>/ Panther 10.3.4)
>The test "answer hostNameToAddress("")" returns the two 
>Google's dns.

I'd be comfortable that would always work - that's what's documented :-)

My example was using an empty string for host (i.e. fully qualified domain
name) - which I expected would default to the local machine, though the docs don't specify it.

As I later realized, the original request was for a way to get
>the ip address provided by the ISP

which I interpret as "the IP address facing the internet" or "... attached to the internet". It will only be provided by the ISP in the case of an interface directly connected to a dial-up, broadband or similar network.

If you have such a machine, and it has no other active IP interface, then I'd expect hostNameToAddr("") to give the correct value (though I can't verify whether it does right now).

If you have a machine which is connected only to a local network (e.g. 
behind a DSL router, or on  a private local net) then I'd expect that to also work.

But if you had a machine with multiple IP interfaces (e.g. a Windows machine attached to a DSL line and running Windows Internet Connection Sharing, or a Linux box configured as a router), then I don't know if it's predictable which interface address you'd get back. I'd *expect* it to be the lowest numbered IP address (though  I wouldn't guarantee it), and that may well not be the one that is attached to the internet.

Dar's solution of opening a UDP socket to a public address should always get the IP address of an interface which can reach the internet.

But then we come back to the intent of the original question ....
Roger - why do you want to get the IP address, and what kind of thing do you want to use it for ?  The reason it matters is the possibility of there being a NAT box between the local machine and the internet - in which case the local IP address may well not be addressable from the internet.

-- Alex.

More information about the use-livecode mailing list