By default, geth
uses port 30303 for connection to other nodes. You may need to modify your firewall to allow traffic over this port.
You can check your peer count as well as getting a list of peers when attached to the javascript console (geth attach
).
instance: Geth/v1.3.2/darwin/go1.5.1
datadir: /Users/home/Library/Ethereum
coinbase: 0xd3cda913deb6f67967b99d67acdfa1712c293601
at block: 864339 (Sun, 17 Jan 2016 16:00:07 MST)
modules: admin:1.0 db:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 shh:1.0 txpool:1.0 web3:1.0
> net.peerCount
5
> admin.peers
[{
caps: ["eth/61", "eth/62"],
id: "03743aa20db17dc12d2e355f32b75964653408eaab2c6e0fad7b2600fef49b3c2ec938d436fc48e86582d732d8eb64935edddee7d5c9caf726261add05cf46fe",
name: "Geth/v1.2.2/linux/go1.5",
network: {
localAddress: "10.0.1.48:30303",
remoteAddress: "87.106.88.35:35646"
},
protocols: {
eth: {
difficulty: 2283869820384174300,
head: "d0d57a2f8fea1c834ce277d031727fecc1baf617b69e4d169f87f7e2d56f04c6",
version: 62
}
},
...
]
If you have a healthy geth node running somewhere else you can try bootstrapping your peer connection with the admin.addPeer
function. The function should be called with an enode address in the format of admin.addPeer("enode://<id>@<ip_address>:<port>")
where the ip_address
and port
values come from the remoteAddress
portion of the peer information and the id
is the big long hex string under the id
key for the peer info. For the peer above, this would be:
admin.addPeer("enode://03743aa20db17dc12d2e355f32b75964653408eaab2c6e0fad7b2600fef49b3c2ec938d436fc48e86582d732d8eb64935edddee7d5c9caf726261add05cf46fe@87.106.88.35:35646")
This can be useful if you somehow lose connection to all of your peers through some non-network based mechanism. However, not having any peers is likely to be a networking issue and manually adding peers will potentially only server as a stop-gap solution at best.
Yes, you can make a file called static-nodes.json, containing the enode address (basically IP + public key).
See the example on the Geth wiki.
Alternatively I haven't tried this but according to this answer you can make a file called trusted-nodes.json with the same content, then set max peers to a low number (zero?) so your node doesn't connect to anyone else.
To be on the safe side you may well want to firewall your nodes off as well, either by specifying their IPs or by connecting them via SSH tunnels or a VPN or whatever.
Best Answer
For an ethereum geth node you can specify the maximum number of peer with help of the
--maxpeers
command-line flag (see https://github.com/ethereumproject/go-ethereum/wiki/Command-Line-Options). It defaults to 25. This limits depends on the node type (e.g. parity or ccp-ethereum have different defaults)See also
Ethereum selection of peer nodes and centralization
https://forum.ethereum.org/discussion/9007/how-many-peers-does-one-node-have
Does the number of geth's maxpeers option include it's own node?
With regard to bitcoin I found this stackexchange entry that states that the limit is 125 (8 outbound+117 inbound) see https://bitcoin.stackexchange.com/questions/44504/is-there-a-connections-limit-on-bitcoind