1

I need to establish a TCP connection with another computer (that is not in the same network) without knowing their IP address. Both are running the same TCP server software, however, since their IP addressing is not static, I won't know their IP addresses, however, I will know any other static network information on their computer (MAC address, etc.)

Is there any way to find an IP address or make a TCP connection with only static network information?

1 Answer 1

2

The standards-track way to do this involves setting up your domain's DNS server to support IETF-standards-track DNS dynamic updates, then run a process on your device that updates its DNS record when its IP address changes.

The non-standard, but widely-deployed way of doing this (I guess that makes it a de facto standard) is to use a Dynamic DNS (DDNS) service, the most famous of which is probably dyn.com. It's the same idea as above; you'll need to run a process on your device that updates your device's DNS records when its IP address changes.

If one or both devices are behind NAT gateways, they might not even know their own public IP address and may not even have a port that is reachable from the public Internet. This problem is known as "NAT Traversal" and is an area that ICE, STUN, and TURN seek to address.

Your server process must first discover its public IP address and port tuple at which it can be reached (note: this might not be its own local IP address and port if it's behind a NAT gateway), and then it must communicate that tuple to the client somehow. This involves the problems of "peer discovery" and "interactive connection establishment" and "NAT traversal". Most solutions to this set of problems require some kind of publicly-reachable server with a stable hostname to act as a place where devices that accept connections can post their tuples. Alternatively, that publicly-reachable server can act as a traffic relay/proxy, where your "server" process makes an outgoing connection to the public host, and then your "client" process makes its own outgoing to the public host, and the public hosts forwards traffic between the two connections.

In short, this is not very easy to do. It's kind of a hassle. It might be easier to set up static IP addresses and static port mappings in your NATs after all.

3
  • I don't have a domain and I'm unlikely to get one for this purpose, are there any other workarounds?
    – dthusian
    Commented Nov 9, 2019 at 0:30
  • FYI: A domain from google.com/domains is $12/yr so the cost/difficulty of setting up a domain is low.
    – cybernard
    Commented Nov 9, 2019 at 1:50
  • 1
    @forthe: You don't need a whole domain really. A subdomain from a public-use domain provided by the same DynDNS provider can be as low as $0/yr (i.e. completely free). Although the good old .dyndns.org has been closed down, there are still many other such services. Commented Nov 9, 2019 at 7:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .