4

I am trying to setup a private ethereum chain and connect two peers to it. I followed this tutorial on github. One of the two peers ran from a windows 10 geth client. The other ran from a Ubuntu geth client (Ubuntu itself ran on Virtual Box).

I started off by creating a genesis block (genesis.json) on the windows client:

{

"config": {

"chainId": 19,

"homesteadBlock": 0,

"eip155Block": 0,

"eip158Block": 0

},

"difficulty": "15",

"gasLimit": "2100000",

"alloc": {}

}

Then I ran in cmd :

geth --datadir path/to/data init genesis.json

After that, I created the bootnode:

bootnode --genkey = boot.key

and

bootnode --nodekey = node.key

I then received

self=enode://6b2700c843fb78732706a2b687ce751a2fbaf7d9034f455f5037af68f1ca0c1a52824cd178f17bc994af9c489d9e3ed0795900ae0efe4eacafb1e8653dc3eb6e@[myip]:30301

My understanding is that this enode will point the future peers to the genesis block and other peers. Here is the problem. I am able to ping myip,yet

telnet myip 30301

is unsuccessful. I suspect that i did not use the correct Ip address. I tried using the ipv4 address found from ipconfig, as well as my ipv4 address that I looked up online (probably given by the service proider) with no avail.

  • Most versions of telnet only operate on TCP, the bootnode listens to UDP connections on 30301. You can test the port with netcat instead, does this help? – javahippie Feb 22 '18 at 12:55
2

If you can't telnet then there is something wrong with your networking. Either your virtual network connection between hosts is the problem or there is a firewall blocking connections.

If you are just getting started then I'd keep things really simple first of all and:

  • Use standard geth nodes
  • Run your nodes on one virtual machine on different ports

e.g. initialise your geth nodes like this:

ethuser@host01:~$ mkdir test1
ethuser@host01:~$ cd test1
ethuser@host01:~/test1$ mkdir nodeA
ethuser@host01:~/test1$ mkdir nodeB
ethuser@host01:~/test1$ <use your favourite editor to create a genesis.json file in this directory>
ethuser@host01:~/test1$ geth --datadir nodeA init genesis.json
WARN [08-04|10:41:41] No etherbase set and no accounts found as default 
INFO [08-04|10:41:41] Allocated cache and file handles         database=/home/ethuser/test1/nodeA/geth/chaindata cache=16 handles=16
INFO [08-04|10:41:41] Writing custom genesis block 
INFO [08-04|10:41:41] Successfully wrote genesis state         database=chaindata                                hash=dd3f8d…707d0d
INFO [08-04|10:41:41] Allocated cache and file handles         database=/home/ethuser/test1/nodeA/geth/lightchaindata cache=16 handles=16
INFO [08-04|10:41:41] Writing custom genesis block 
INFO [08-04|10:41:41] Successfully wrote genesis state         database=lightchaindata                                hash=dd3f8d…707d0d
ethuser@host01:~/test1$ geth --datadir nodeB init genesis.json
WARN [08-04|10:41:52] No etherbase set and no accounts found as default 
INFO [08-04|10:41:52] Allocated cache and file handles         database=/home/ethuser/test1/nodeB/geth/chaindata cache=16 handles=16
INFO [08-04|10:41:52] Writing custom genesis block 
INFO [08-04|10:41:52] Successfully wrote genesis state         database=chaindata                                hash=dd3f8d…707d0d
INFO [08-04|10:41:52] Allocated cache and file handles         database=/home/ethuser/test1/nodeB/geth/lightchaindata cache=16 handles=16
INFO [08-04|10:41:52] Writing custom genesis block 
INFO [08-04|10:41:52] Successfully wrote genesis state         database=lightchaindata                                hash=dd3f8d…707d0d
ethuser@host01:~/test1$ 

Then launch your first geth node like this

ethuser@host01:~/test1$ geth --datadir nodeA --networkid 1234567 console
WARN [08-04|10:42:22] No etherbase set and no accounts found as default 
INFO [08-04|10:42:22] Starting peer-to-peer node               instance=Geth/v1.6.7-stable-ab5646c5/linux-amd64/go1.8.1
INFO [08-04|10:42:22] Allocated cache and file handles         database=/home/ethuser/test1/nodeA/geth/chaindata cache=128 handles=1024
WARN [08-04|10:42:22] Upgrading chain database to use sequential keys 
INFO [08-04|10:42:22] Initialised chain configuration          config="{ChainID: 1907 Homestead: 0 DAO: <nil> DAOSupport: false EIP150: <nil> EIP155: 0 EIP158: 0 Metropolis: <nil> Engine: unknown}"
INFO [08-04|10:42:22] Disk storage enabled for ethash caches   dir=/home/ethuser/test1/nodeA/geth/ethash count=3
INFO [08-04|10:42:22] Disk storage enabled for ethash DAGs     dir=/home/ethuser/.ethash                 count=2
WARN [08-04|10:42:22] Upgrading db log bloom bins 
INFO [08-04|10:42:22] Bloom-bin upgrade completed              elapsed=252.683µs
INFO [08-04|10:42:22] Initialising Ethereum protocol           versions="[63 62]" network=1234567
INFO [08-04|10:42:22] Database conversion successful 
INFO [08-04|10:42:22] Loaded most recent local header          number=0 hash=dd3f8d…707d0d td=40
INFO [08-04|10:42:22] Loaded most recent local full block      number=0 hash=dd3f8d…707d0d td=40
INFO [08-04|10:42:22] Loaded most recent local fast block      number=0 hash=dd3f8d…707d0d td=40
INFO [08-04|10:42:22] Starting P2P networking 
INFO [08-04|10:42:22] UDP listener up                          self=enode://9ce583f7e1905b23217cd2a92894291c6d8f5ce7a29e85fdeaf48b3ab065c6d5b6cce4f064fdaf26f41d2354bf0a203438563f6ffdba73cec3b8692f6f850817@[::]:30303
INFO [08-04|10:42:22] RLPx listener up                         self=enode://9ce583f7e1905b23217cd2a92894291c6d8f5ce7a29e85fdeaf48b3ab065c6d5b6cce4f064fdaf26f41d2354bf0a203438563f6ffdba73cec3b8692f6f850817@[::]:30303
INFO [08-04|10:42:22] IPC endpoint opened: /home/ethuser/test1/nodeA/geth.ipc 
Welcome to the Geth JavaScript console!

instance: Geth/v1.6.7-stable-ab5646c5/linux-amd64/go1.8.1
 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

> 

And then start up your second node. In my case I needed to use ethuser@host01:~/test1$ geth --datadir nodeB --port 30304 --networkid 1234567 --bootnodes enode://9ce583f7e1905b23217cd2a92894291c6d8f5ce7a29e85fdeaf48b3ab065c6d5b6cce4f064fdaf26f41d2354bf0a203438563f6ffdba73cec3b8692f6f850817@127.0.0.1:30303

Wait a few moments to give the nodes a chance to connect and then double check in your console that admin.peers returns some more info, e.g.

> admin.peers
[{
    caps: ["eth/63"],
    id: "9ce583f7e1905b23217cd2a92894291c6d8f5ce7a29e85fdeaf48b3ab065c6d5b6cce4f064fdaf26f41d2354bf0a203438563f6ffdba73cec3b8692f6f850817",
    name: "Geth/v1.6.7-stable-ab5646c5/linux-amd64/go1.8.1",
    network: {
      localAddress: "127.0.0.1:41900",
      remoteAddress: "127.0.0.1:30303"
    },
    protocols: {
      eth: {
        difficulty: 40,
        head: "0xdd3f8d61f38ebc195a6c9b0e5888e7e035f31ecd92e4427fb01176b984707d0d",
        version: 63
      }
    }
}]
> 

I've left out creating accounts etc as you don't specifically ask it but if you're interested here are some more of my own newbie experiences: https://alanbuxton.wordpress.com/2017/07/19/first-steps-with-ethereum-private-networks-and-smart-contracts-on-ubuntu-16-04/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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