how to connect nodes over the internet in a private network

islandBillyislandBilly Member Posts: 12
Something like this has been being asked for literally years with no straight answer. I have two geth nodes separated by hundreds of miles. They are both running geth1.8.10 and used the same custom genesis file to initialize, ie I initialized one node with that file and sent a copy of the customGenesis file to the other node where it was used in the geth init. They also use the same network id and other params when they run. Over the internet they do NOT sync, and though messages indicate they connect, handshake fails due to genesis block mismatch. What is going on?? Here is the genesis file:
"nonce": "0x0000000000004242", "timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x8000000",
"difficulty": "0x400",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x3333333333333333333333333333333333333333",
"config": {
"chainId": 42,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
"alloc": {
"": { "balance": "100000000000000000" },
"": { "balance": "100000000000000000" }
"extra data": "earth42 Private Voting Blockchain"
I don't run with discovery off, but I have a static-node.json file to connect to the other node. I also have used admin.addPeer to do it. They connect but never sync due to genesis block mismatch. How can the genesis block possibly be mismatched when we use identical files (except for the accounts in alloc)?? I created two nodes before this with geth1.5.5 and on the same subnet, the two machines had no trouble connecting and syncing; but not over the internet. What is the f-ing difference??

Best Answer

  • islandBillyislandBilly Posts: 12
    Accepted Answer
    So here is the answer to my slightly testy question. The genesis.json file MUST be identical for multiple nodes to be able to connect. That includes the alloc{} section, which therefore must be empty. So then once you have initialized the node, you can just turn on mining, and even with nothing to do, the miner will generate a bunch of ether in a matter of 30 seconds, so you will be able to do things with your account and still have the critical genesis block match to other nodes. Every one of the parameters affects the resulting genesis hash EXCEPT the extraData, which is pretty much ignored anyway.


  • islandBillyislandBilly Member Posts: 12
    Okay, I have done some testing (with geth v1.8.10) and have discovered some interesting things that I did not expect.

    one is that when you change the contents of the {alloc} section of the genesis.json file, you change the the resulting hash of the genesis block. This alone can cause genesis block mismatch when a node on one machine tries to allocate ether to its account, and its would-be peer allocates ether to a different account. I have proved this by comparing hashes of the genesis block. So it would be extremely cumbersome if we all use an identical CustomGenesis.json file that Must include an indentical {alloc} section with all our accounts in it, and so if we omit the {alloc} section, then how do we get some ether to our private network accounts? This may be trivial to those who want to stay on the main net, but in creating a private network for a particular purpose, I am rendering the ether-money aspect trivial, and I need to process transactions. So how do I allocate any ether to a private account after the fact of init-ing the private nodes?
Sign In or Register to comment.