Ethereum Private Network Setup with Geth: Adding Nodes and Understanding Static Nodes

·

Setting up a private Ethereum network is a foundational step for developers looking to test decentralized applications (dApps), smart contracts, or blockchain configurations in a controlled environment. One of the most powerful tools for this purpose is Geth (Go Ethereum), the official Go implementation of the Ethereum protocol. In this guide, we’ll walk through how to build a multi-node private blockchain using Geth, focusing on both dynamic and static node addition, and explain what static nodes are and why they matter.

Whether you're exploring blockchain architecture or preparing for enterprise-level deployment, understanding peer connectivity in a private network is essential. This article dives deep into practical setup steps while integrating core concepts naturally for better comprehension and SEO performance.


Core Keywords

These keywords reflect common search intents from developers seeking hands-on guidance for setting up Ethereum test environments.


Setting Up a Multi-Node Private Blockchain with Geth

Creating a functional private Ethereum network with multiple nodes allows you to simulate real-world conditions such as peer discovery, synchronization, and transaction propagation. We’ll use two virtual machines (VMs) to represent separate nodes communicating over a local network.

Step 1: Network Configuration and Prerequisites

Before establishing connections between nodes, ensure both VMs are on the same network and can reach each other.

Run the following command to check your IP address:

ifconfig

If the command isn’t found, install the necessary tools:

sudo apt-get install net-tools

Assuming:

Ensure both machines can ping each other to confirm connectivity.

👉 Learn how blockchain networks power decentralized ecosystems — explore development tools today.


Step 2: Prepare Genesis File and Initialize Nodes

The genesis.json file defines the initial state of your blockchain. If you’ve already created one in a previous step (e.g., during single-node setup), copy it — along with the keystore folder containing account keys — from VM A to VM B.

On VM B, initialize the node using the shared genesis configuration:

geth --datadir "./" init genesis.json

This creates the necessary directory structure and applies the custom blockchain rules defined in the genesis block.


Step 3: Start Both Nodes

Launch the Geth console on each machine with matching network settings to ensure compatibility.

On VM A:

geth --datadir "./" --networkid 989898 --rpc --rpcaddr "0.0.0.0" --rpcport 8546 --port 30304 --nodiscover console

On VM B:

geth --datadir "./" --networkid 989898 --rpc --rpcaddr "0.0.0.0" --rpcport 8546 --port 30304 --nodiscover console
🔍 Note: The --networkid must be identical across all nodes to allow them to recognize each other as part of the same network. The --nodiscover flag disables automatic peer discovery, giving you full control over which nodes connect.

Step 4: Retrieve Node Information

Inside the Geth console on VM B, retrieve its enode URL:

admin.nodeInfo.enode

You’ll see output similar to:

"enode://f6011e1cd370cac0decbaf71fc6a115486260d7ca8580c4493dbc739fa8e52a3dacda0090075b3d4b8a086d79f6af453df2e7475adf94c7bb37f041586439acb@[::]:30304"

Replace [::] with VM B’s actual IP:

"enode://[email protected]:30304"

This forms the complete enode URL, which uniquely identifies the node on the network.


Step 5: Dynamically Add a Peer Node

Now return to VM A’s Geth console and add VM B as a peer:

admin.addPeer("enode://f6011e1cd370cac0decbaf71fc6a115486260d7ca8580c4493dbc739fa8e52a3dacda0090075b3d4b8a086d79f6af453df2e7475adf94c7bb37f041586439acb@192.168.209.134:30304")
✅ Success? Check with:
net.peerCount
admin.peers

If peerCount returns 1 and admin.peers shows connection details, your nodes are now communicating.


What Are Static Nodes in Geth?

Static nodes are predefined peers that a Geth node will automatically connect to at startup and attempt to maintain a persistent connection with. Unlike trusted nodes, static nodes aren’t given special privileges but are prioritized during reconnection attempts.

Using static nodes simplifies network management in private blockchains where you want consistent topology without manual intervention every time a node restarts.

How to Configure Static Nodes

To set up static node connections:

  1. Navigate to the geth subdirectory within your data directory:

    cd ./geth
  2. Create or edit the static-nodes.json file:

    gedit static-nodes.json
  3. Add the enode URL(s) of trusted peers:

    [
      "enode://f6011e1cd370cac0decbaf71fc6a115486260d7ca8580c4493dbc739fa8e52a3dacda0090075b3d4b8a086d79f6af453df2e7475adf94c7bb37f041586439acb@192.168.209.134:30304"
    ]

Save and close the file.

Now, whenever this node starts, it will automatically connect to the specified peer — no need to manually call addPeer().


Benefits of Using Static Nodes

👉 Discover how developers use private chains to innovate securely — start experimenting now.


Frequently Asked Questions (FAQ)

Q: What is the difference between a static node and a trusted node in Geth?

A: A static node is automatically connected to at startup and remains a preferred peer unless removed. A trusted node goes further by allowing certain actions like proposing snapshots in Clique consensus or bypassing spam protection checks. Trust must be explicitly granted via admin.addTrustedPeer().

Q: Why isn't my node connecting even after using addPeer()?

A: Common causes include:

Q: Can I add multiple static nodes?

A: Yes! Simply list multiple enode URLs in the static-nodes.json file, separated by commas:

[
  "enode://node1...",
  "enode://node2...",
  "enode://node3..."
]

Q: Do both nodes need to list each other in static-nodes.json?

A: Not necessarily. If only Node A lists Node B, Node A will initiate the connection. However, bidirectional listing ensures robustness if either node restarts independently.

Q: Is it safe to expose RPC ports (--rpcport) on a private network?

A: On isolated internal networks, yes — but always restrict access via firewall rules. Avoid exposing RPC ports to public internet without authentication layers like JWT or reverse proxies.

Q: How do I stop or reset my private chain?

A: To cleanly shut down, use exit in the Geth console. To reset, delete the data directory (--datadir) and reinitialize with genesis.json. Be sure to back up keys first.


Final Thoughts

Mastering node management in a private Ethereum network using Geth empowers developers to simulate complex decentralized systems efficiently. Whether you're dynamically adding peers for quick tests or configuring static nodes for stable development environments, these skills form the backbone of blockchain engineering.

By understanding enode addressing, network configuration, and peer persistence mechanisms, you lay a solid foundation for advancing into consensus algorithms, smart contract deployment, and cross-node transaction testing.

👉 Take your blockchain projects further — access developer resources and tools here.