When a new Bitcoin node starts, it must discover other nodes in the network to participate in the decentralized ecosystem. Unlike traditional networks, Bitcoin’s node topology isn’t based on geographical proximity—nodes connect randomly to create a resilient and distributed peer-to-peer network.
To join the network, a node needs to establish at least one connection with an existing Bitcoin node. Communication typically occurs over the TCP protocol on port 8333 (the default port for Bitcoin, though other ports can be used).
Establishing the Initial Connection
Once a node identifies a peer, it initiates a "handshake" using a version message. This message contains essential identification and capability details:
- nVersion: The Bitcoin P2P protocol version used by the client (e.g., 70002).
- nLocalServices: A list of supported services; currently, only
NODE_NETWORKis widely used. - nTime: The current timestamp.
- addrYou: The IP address of the remote node.
- addrMe: The IP address of the local node.
- subver: A string identifying the node’s software (e.g., "/Satoshi:0.9.2.1/").
- BaseHeight: The current block height of the node’s blockchain.
The version message is always the first communication between two peers. The receiving node checks the nVersion field to determine compatibility. If accepted, it responds with a verack message to confirm the connection.
How New Nodes Find Peers
New nodes use one of two primary methods to discover peers.
DNS Seeds
BitCore Core clients include built-in DNS seeds—specialized servers that provide a list of Bitcoin node IP addresses. Some DNS seeds offer static IP lists, while others use custom implementations (like BIND) to return random subsets of nodes gathered from crawlers or long-running clients.
The diversity and reliability of multiple DNS seeds ensure robust bootstrapping. By default, Bitcoin Core uses DNS seeds (controlled by the -dnsseed=1 option).
Manual Peer Entry
Nodes can also be manually configured with specific peer IP addresses. The -seednode option allows a node to connect to a designated peer solely for introductions. After discovering new peers, the client disconnects from the seed node and establishes connections with the newly discovered nodes.
Address Propagation and Discovery
After establishing initial connections, nodes share address information to strengthen network connectivity.
- A new node sends an
addrmessage containing its IP address to its neighbors. - Neighbors propagate this message to their peers, ensuring broad awareness of the new node.
- The new node can also send a
getaddrmessage to request known peer addresses from neighbors.
This process helps nodes discover diverse peers and integrate into the network efficiently.
Maintaining Network Connections
Nodes must continuously manage connections to accommodate network churn—peers joining and leaving frequently. Key behaviors include:
- Discovering new peers when existing connections drop.
- Assisting other new nodes in bootstrapping.
- Remembering recent successful peers for faster reconnection after restarts.
Bitcoin Core nodes use the getpeerinfo command to list active peer connections:
$ bitcoin-cli getpeerinfoUsers can override automatic peer management with the -connect=<IP> option, forcing the node to connect only to specified addresses.
To prevent stale connections, nodes send periodic messages. If no communication occurs for 90 minutes, the connection is dropped, and the node seeks new peers.
This dynamic, self-adjusting system allows the Bitcoin network to scale organically without central coordination.
Frequently Asked Questions
Why does a new node need to discover peers?
A new node must find peers to participate in the Bitcoin network. Peer connections enable transaction relay, block propagation, and consensus without relying on central servers.
What is the role of DNS seeds?
DNS seeds provide new nodes with initial peer IP addresses. They offer a reliable and decentralized bootstrapping mechanism, ensuring nodes can join the network even if some seeds are unavailable.
Can I run a node without using DNS?
Yes. You can manually specify peer IPs using the -connect or -seednode options. This is useful in restricted or private network environments.
How does the network handle node disconnections?
Nodes continuously monitor connections. If a peer is unresponsive for 90 minutes, the node disconnects and searches for new peers. This ensures network resilience and adaptability.
What information is exchanged during the handshake?
The version message shares protocol version, IP addresses, software type, and blockchain height. This helps peers verify compatibility and establish secure communication.
Is node discovery anonymous?
While IP addresses are shared during discovery, the network doesn’t require identity disclosure. However, node operators can use privacy tools like Tor to mask their IP addresses.