0

I'm trying to build a local private blockchain of Ethereum in my own PC using Geth v1.9.15-stable-0f77f34b. I have installed Geth in a virtual machine with Ubuntu 18.04 OS using VMware Workstation Pro. I want to create two miners inside the virtual machine. Each runs in different terminal, I have follow this steps:

1)create two nodes:

geth --datadir node1 account new
geth --datadir node2 account new

2)genesis.json

{
    "nonce": "0x0000000000000042",
    "timestamp": "0x0",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "0x",
    "gasLimit": "0x8000000",
    "difficulty": "0x400",
    "config": {},
    "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "coinbase": "0x3333333333333333333333333333333333333333", "alloc": { }
}

3)initialize genesis:

geth --datadir node1 init ./genesis.json
geth --datadir node2 init ./genesis.json

4)To enable nodes I use:

geth --identity "name_of_your_node" --rpc --rpcport "8000" --rpccorsdomain "*" --datadir mode1 --port "30303" --nodiscover --rpcapi "db,eth,net,web3,personal,miner,admin" --networkid 1900 --nat "any"

geth --identity "name_of_your_node" --rpc --rpcport "8001" --rpccorsdomain "*" --datadir mode2 --port "30301" --nodiscover --rpcapi "db,eth,net,web3,personal,miner,admin" --networkid 1900 --nat "any"

5)Interconnect nodes:

geth attach http://127.0.0.1:8001
geth attach http://127.0.0.1:8000

6)Make Node1 as an admin node, I use this code to find info:

admin.nodeInfo
{
  enode: "enode://b378a4f7d9454811a89954cb97bb19589564a8e1ef24ebda07c25c2ae2a8acf35c4c14b2fd84d2a0cf92b1586eff0ea592de5f8effb0e08b1616917edf3306f1@100.69.54.149:30303?discport=0",
  enr: "enr:-JO4QI-9oLlq2ZVbjMfEry_Kk7VJ65divD9HL7jFC3tl2WwkbTc6Bc4sIqaD9MTKAEQuDfWqSw_bwoy2nqy5MAfYgssHg2V0aMrJhPxk7ASDEYwwgmlkgnY0gmlwhGRFNpWJc2VjcDI1NmsxoQOzeKT32UVIEaiZVMuXuxlYlWSo4e8k69oHwlwq4qis84N0Y3CCdl8",
  id: "fb25937ad7ced1cf77a820fc34f93d42135cf2760508db94dd56c2ca05bb92b5",
  ip: "100.69.54.149",
  listenAddr: "[::]:30303",
  name: "Geth/name_of_your_node/v1.9.15-stable-0f77f34b/linux-amd64/go1.14.2",
  ports: {
    discovery: 0,
    listener: 30303
  },
  protocols: {
    eth: {
      config: {
        byzantiumBlock: 4370000,
        chainId: 1,
        constantinopleBlock: 7280000,
        daoForkBlock: 1920000,
        daoForkSupport: true,
        eip150Block: 2463000,
        eip150Hash: "0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0",
        eip155Block: 2675000,
        eip158Block: 2675000,
        ethash: {},
        homesteadBlock: 1150000,
        istanbulBlock: 9069000,
        muirGlacierBlock: 9200000,
        petersburgBlock: 7280000
      },
      difficulty: 17179869184,
      genesis: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
      head: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
      network: 1900
    }
  }
}

7)another node I use this code to connect to node 1:

admin.addPeer("enode://b378a4f7d9454811a89954cb97bb19589564a8e1ef24ebda07c25c2ae2a8acf35c4c14b2fd84d2a0cf92b1586eff0ea592de5f8effb0e08b1616917edf3306f1@100.69.54.149:30303?discport=0")
true

8)but the nodes are not connected:

> net.peerCount
0
> net.listening
true

Have I missed something? please help? I have another question: why the IP in admin.nodeInfo is "100.69.54.149", it's not my IP how to change that?

2
  • By default geth tries to use your external ip, you can disable that by adding --nat none to the command line, an alternative is to tell him explicitly your address --nat extip:<IP address>. See other command line parameters here geth.ethereum.org/docs/interface/command-line-options.
    – Ismael
    Jun 22, 2020 at 14:23
  • Please, add the command line used as an answer so it can help others in a similar situation.
    – Ismael
    Jun 23, 2020 at 15:06

1 Answer 1

0

The solution is to add --nat none to geth --identity "name_of_your_node" --rpc --rpcport "8000" --rpccorsdomain "*" --datadir mode1 --port "30303" --nodiscover --rpcapi "db,eth,net,web3,personal,miner,admin" --networkid 1900 --nat none

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.