I think this is where I'm starting to get confused
Ok. based on your scenario description, you have a server. No problem. If the server is on an intranet, and all clients are connecting from the same intranet, to the server there should be no real gateway issues, and all clients should have a unique (to the intranet) private IP. If all clients have a public IP, then there is no real problem either, though it would be a security nightmare.
Say the private ip of your intranet had a range of 192.168.1.1 to 192.168.1.254.. If you add in outside users who are behind a nat using the same range, there can be duplicate IPs IE 192.168.1.25 coming from several different locations. So that isn't really a useful number to know.
Then there is the nat gateway itself. If they are hitting your server from outside, and say there are 3 computers behind the nat, then each system could have an address in the same range also, so you could have 192.168.1. 10,11,12 so each of those would have their own unique internal, the problem of course being they could match ips of other networks internal nat ips. Again this really doesn't matter, its just that it doesn't seem that having this information would really be useful.
YOU could have the server return the perceived address when they connect, but again this can be wierd. If there are 3 systems behind a nat gateway, then the ip the server would see is that of the gateway itself. If I understand this part correctly, packets are tagged by the mac address of the internal system itself, allowing the nat gateway to know where to send returning packets based on mac address, not ip. Is there a heavy duty network person that can confirm this?
What all this boils down to, is that if I want to run apache web server for example and have it accessible from the outside, knowing my private internal ip is just a small step to getting this setup. In addition I have to make sure my dsl box is configured to forward port 80, AND my internal nat gateway has to be configured also, either using port forwarding, or setting up a dmz. Which brings us back to the issue with multiple computers behind a nat gateway. As far as I know you can setup 1 machine as dmz where everything is forwarded, so you couldn't easily hit the additional machines. Same with port forwarding I believe.
If you just want to display a clients IP just to display it, then I'd say the last code you posted is fine.
I have one question regarding all this stuff myself. How does push work? It seems to me that the client has to maintain some type of tenuous contact with a server for push to work.. Initially instigated by the client. Do I misunderstand this? Then when there is a server change, it shoves the changes down to the client using that already existing connect.
If I DO misunderstand this, (which is likely) could someone help clarify? Perhaps push technology is where your questions are headed trevix.
trevix wrote:Yes, the "checkip" shell script works for the external IP, thanks...but let me explain:
I'm doing a Windows/Osx client/server calendar for small companies, where the server records event datas on a commercial database. (In this explanation off course "Server" is the "calendar server application", "Client" is the "calendar client application".)
The server sits on the company server or a computer in the intranet, togheter with the database.
The clients are on local network computers or sits outside and connect trough internet.
In order to connect, I've choosen to have the server admin to write every user IP (and name and PW) in the calendar server preferences.
The clients have to write the server IP on the calendar client preferences.
So, there is no problem for the server administrator to voice-communicate the IP of the server to the clients so that they can connect (he knows where to look).
But I would like the clients to easily see their IP on a presented Runrev window.
What also if the Ip is static ? What happens ? The "Checkip" is the external, but each computer on the intranet will still have a local IP
--------------
For what I know, most of them will have a Dynamic external address (by their ISP), a router and a number of internal IPs (for each client and server)
So i guess I need each PC to find their "internal" IP.
But it all fits down to this: On the OS network preferences both on Windows and OSX it is shown the IP that I need. How can I get it ?
(as I said before, the "hostanametoaddress" gets it, but with other IPs that I do not know with which rule to parse)
Thanks for any help