Skip to content

P2p_networking

Blockchain nodes communicate through Peer-to-Peer (P2P) networks. Understanding P2P networking is essential for node operators.


┌─────────────────────────────────────────────────────────────────┐
│ P2P NETWORK OVERVIEW │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Each node connects to multiple peers │
│ │
│ Node A │
│ / | | \ │
│ / | | \ │
│ / | | \ │
│ B C D E │
│ │
│ Transactions flow: A → B, C, D, E │
│ Blocks propagate: A → B → C → D → E │
│ │
│ No central server - fully decentralized │
│ │
└─────────────────────────────────────────────────────────────────┘

MethodDescription
BootnodesWell-known nodes for initial connection
DNS DiscoveryDNS-based peer discovery
DiscV5Ethereum’s new discovery protocol
KademliaDHT-based peer discovery
# Mainnet bootnodes
enr:-KG4QOtcL...@bootnode.mainnet.ethdisco.net:30303
# Connect to specific peers
geth --bootnodes "enr:-KG4..."

ProtocolPortDescription
TCP P2P30303Ethereum mainnet
UDP Discovery30303Peer discovery
HTTP RPC8545JSON-RPC
WebSocket8546WS API
Terminal window
# Allow P2P
sudo ufw allow 30303/tcp
sudo ufw allow 30303/udp
# Allow RPC (restrict to your IP)
sudo ufw allow from YOUR_IP to any port 8545
# Allow WebSocket
sudo ufw allow 8546/tcp

Terminal window
# In Geth console
admin.peers() # List all peers
admin.addPeer("enr:...") # Add specific peer
# Check peer count
net.peerCount
Terminal window
# config.toml
[Node]
StaticNodes = ["enr:...", "enr:..."]

IssueCauseSolution
No peersFirewall, networkCheck ports, add bootnodes
Peer dropsNetwork issuesCheck connectivity
Sync stuckPeer issuesTry different peers
Terminal window
# Check network info
curl http://localhost:8545 -X POST -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":1}'
# Check enode
geth attach http://localhost:8545
admin.nodeInfo.enode

  • P2P networks enable decentralized communication
  • Bootnodes help new nodes discover peers
  • Proper firewall configuration is crucial
  • Monitor peer count for network health

In Chapter 24: Node Discovery Protocols, we’ll explore discovery in detail.


Last Updated: 2026-02-20