On Mon, Aug 03, 2020 at 02:38:13PM -0600, Charles Curley wrote: > On Mon, 3 Aug 2020 15:18:46 -0400 > Greg Wooledge <wool...@eeg.ccf.org> wrote: > > > On Mon, Aug 03, 2020 at 02:15:17PM -0500, David Wright wrote: > > > The home PC that I'd be trying to contact has a 192.168.n.n IP > > > address given to it by my primary router. But the router's external > > > address is obtained by its DHCP client talking to my ISP's DHCP > > > server. > > > > In a case like that, just contact an external web site that tells you > > what your externally visible IP address is. There are many of them. > > Mine is <http://wooledge.org/myip.cgi>. > > > > Ah, now you are back to using an external server, which the OP would > like to avoid.
The only way you can do this without ANY external help is if one of the two endpoints has a static IP address. Then you can have the dynamic one contact the static one by its static IP address. If both ends are dynamic, there MUST be some third party help. This may involve dynamic DNS, or email, or web sites, or Dropbox, or whatever you can dream up. Now, in addition to that, my suggestion was simply a response to a tangential exploration of how the dynamic client can DETERMINE what its IP address is, so that it can inform the other endpoint. If the client is behind a local DHCP server, it won't know what the router's external IP address is. How could it? That information is never given to the client by the DHCP server. So the client needs SOME way to determine what information to send to the other endpoint. Using one of the several dozen (hundred?) "what is my IP address" web sites is one such way. Another way would be for the client to send a generic message to the static machine, and then have the static machine determine what IP address the message came from. Doing that is viable if there is a direct communication between the two. If the communication goes through a third party helper (e.g. email), it may still be possible to parse the client's original IP address out of the Received: headers (or analogous tracking information if you're using something other than email). Or it may be impossible, if the third party helper does not reveal such information. Some of you are assuming that the local router offers an API whereby clients inside the LAN can determine what the local router's external IP address is, without going outside the LAN. That may or may not be a thing. I have no idea. Good luck with that.