6

I have joined a private network and it works fine when I add the peers with admin.addPeer but I have to add the peers every time I launch geth.

How can I make the list of peers permanent?

5

There are several categories of nodes in Ethereum:

1. Bootnodes

These are nodes used for bootstrapping purposes, and which are hard-coded into your Geth binary. The hard-coded values can be overridden using the --bootnodes option when running Geth from the command line. Alternatively, the hard-codings can be changed by editing the Geth code and rebuilding from source. In your case, it sounds like these hard-codings haven't been updated with any of the nodes in your private network, which is why you can't connect straight out of the box.

2. Static nodes

These are peers you always want to connect to. They're not necessarily boot nodes. You can set them either by using admin.addPeer command, as you've found, or by editing your <datadir>/static-nodes.json file, as described in the official documentation. In your case, I'd recommend editing this file.

3. Trusted nodes

Slightly different to static nodes, in that connections to these nodes don't count towards the total, limited connection count. As explained here.

  • I looked into p2p directory in the source code, but I didn't find hardcoded server IP addresses for the bootnodes. Do you know what is the file name where these IPs are hardcoded? – Nulik Oct 7 '17 at 3:28
  • Should it be <datadir>/geth/static-nodes.json as mentioned in the docs you linked? This directory contains folders chaindata, lightchaindata, nodes, and files transactions.rlp, LOCK, nodekey – Nyxynyx Jul 17 '18 at 16:19
1

you could when launching geth specify the different nodes separated by commas as follow :

geth --bootnodes enode://pubkey1@ip1:port1,enode://pubkey2@ip2:port2,enode://pubkey3@ip3:port3

More details : https://github.com/ethereum/go-ethereum/wiki/Connecting-to-the-network

to automate the task you could create a batch file in windows or a script in linux

  • I make a comment now long after the answer because since at least last September (when I last tried it) this would not work, the node would expect a bootnode answer and on getting a (valid) node answer it would drop the peer. Took me forever to debug this one. – Nicolas Bernard Apr 11 at 10:00

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.