Bitcoin Core connection logic is split into two main types: inbound and outbound connections. A node will always try to establish and maintain a certain number of outbound connections, whereas only a subset of nodes will accept inbound ones.

Inbound connections

Nodes accepting inbound connections are usually known as reachable nodes, and they are a fundamental resource for the P2P network to operate. Each outbound connection created by a node maps to an inbound connection accepted by another, meaning that connectivity is not possible if some nodes do not accept inbound connections. However, inbound connections are inherently less secure than outbounds, given we do not chose them, and therefore, they could be requested by nodes controlled by the same entity. Hence, the security model of Bitcoin Core’s P2P network relies on outbound connections and we will generally assume all inbound can be malicious.

As per the default maximum amount of inbound connections, when applicable, it is currently 114:

mMaxConnections = 125
m_max_outbound = m_max_outbound_full_relay + m_max_outbound_block_relay + nMaxFeeler;
							 = 8 + 2 + 1 = 11
nMaxInbound = nMaxConnections - m_max_outbound
						= 125 - 11 = 114

Outbound connections

Outbound connections are established and managed by our own node to make sure that our own transactions, if any, can reach the rest of the network, and that our chain of blocks is up to date. At the time of writing, a node maintains three different types of outbound connections:

When establishing outbound connections, the logic for which one to create (if any 1️⃣) goes as follows:

If none of the aforementioned conditions are met, no additional connection is performed during this cycle.