How do Bitcoin nodes with dynamic IP addresses maintain connections? Does a node check for their own external IP every so often, then broadcast it?

  • What do you mean by "maintain connections"? What exactly do you think the problem is with dynamic IP addresses? Connections are handled by TCP, so the connection is maintained by TCP.
    – Andrew Chow
    Jun 11 '18 at 0:11
  • Perhaps it is just a matter of understanding TCP, and how it maintains connections. The problem I imagine is just knowing where to send data if an IP address changes.
    – doffing81
    Jun 11 '18 at 4:37
  • When an IP address changes, the connection just terminates.
    – Andrew Chow
    Jun 11 '18 at 5:34
  • Then what? How does my node still receive data with a dynamic external IP?
    – doffing81
    Jun 11 '18 at 5:36
  • I'll write a full answer
    – Andrew Chow
    Jun 11 '18 at 5:47

Bitcoin works over the TCP layer which requires knowing the IP addresses of two ends of the connection. If one IP address changes, the connection will terminate.

In general, to manage disconnects, Bitcoin Core tries to maintain 8 outgoing connections at all times. It stores the IP addresses of every node that it knows about. These nodes can be ones it has connected to previously or ones that other nodes has told it about. When it loses an outgoing connection, it will attempt to make another outgoing connection to replace that connection.

Thus if all connections happened to be dropped due to a dynamic IP address change, all outgoing connections will be replaced by new outgoing connections from the new IP address. Unfortunately incoming connections will not be replaced and the node will have to wait for its new external IP address to be advertised again by its peers.

A node does not directly advertise its external IP address. Instead other nodes learn of its external IP address from hearing about it from other nodes that have connected to that node.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.