3

Just to preface this, I'm a little new to networking and Ethereum in general, but after looking through some tutorials, I decided that I would like to create a private network/blockchain for my own use and smart contracts. But while I can connect 2 peer nodes on the same machine, I have difficulty connecting 2 peer nodes on different machines.

METHOD 1: The below is one way I've tried this (which works for 2 peers on the same machine; one tutorial I saw had the last 3 flags missing but I decided to include them anyway)

geth --datadir /path/to/genesis --networkid 111 --maxpeers 2 --rpc --rpccorsdomain "*" --nodiscover --ipcdisable --rpcport 30001 --port 8081 console //machine 1

geth --datadir /different/path/to/genesis --networkid 111 --maxpeers 2 --rpc --rpccorsdomain "*" --nodiscover --ipcdisable --rpcport 30002 --port 8082 console //machine 2

And then on machine 1 obtain admin.nodeInfo.enode (which is"enode://d677...b4c5@[::]:8081?discport=0"), and enter on machine 2 admin.addPeer("enode://d677...b4c5@my.ip.address?discport=0).

This returns true but admin.peers remains empty.

METHOD 2: Another way is to do the same thing for machine 1, but instead on machine 2 type:

geth --datadir /different/path/to/genesis --networkid 111 --maxpeers 2 --rpc --rpccorsdomain "*" --nodiscover --ipcdisable --rpcport 30002 --port 8082 --bootnodes enode://d677...b4c5@my.ip.address?discport=0 console

And then do the same admin.addPeer process. Same results happen, however.

I'm really torn as to what is the problem here. The genesis blocks are the same (hashes are the same), and I've tried various types of flags after initializing on both machines. I suppose my hunch is that my clocks are not synced on both machines (although I'm not sure how to do so other than sudo timedatectl set-ntp on), or that I'm not entering the right IP address (although I've tried almost all of them), so maybe some direction in these areas would be nice.

I've tried having --verbosity 6 also, and the error returned is 'discovery is disabled' and 'dial tcp my.ip.address:8081: getsockopt: connection refused'. Which is strange since I had no problem doing this using the same machines, but when I did the same thing without --nodiscover it still didn't work: errors were 'dial tcp my.ip.addresss:8081: i/o timeout' and 'no discv4 seed nodes found' and 'resolving node failed'.

I'm really sorry if this is really long-winded but it's just I'm really unsure of what's the real problem and I've been just iterating through much of these changes that I'm sure about. To make matters worse I think Ethereum and geth are constantly updating so I'm not sure if the information I'm seeing on this site and elsewhere are relevant or accurate. I'd really, really appreciate some help here because I'm really desperate for some help and clarification.

  • Are the machines in the same LAN? Can you ping between them? Did you check if you have a firewall blocking incoming connections in the used ports? – Ismael Jun 19 '17 at 4:46
  • Hi Ismael, both machines are in the same LAN (system settings -> network -> wired return the same thing; whatismyipaddress.com are almost the same, just differs by 1) and to my knowledge there are no firewalls (sudo ufw status returns inactive for both). I am however not sure what you mean by pinging between them, sorry, I am rather clueless about networking. – Avaritia Jun 19 '17 at 5:59
1

1) Just confirm whether both genesis are the same...(use eth.getBlock(0) on both nodes)

2) Try and use admin.addPeer("enode....@IP of the other node:Port") in your console.

You can check the port using admin.nodeInfo

admin.addPeer("enode://93a29e6d51e58c8a313a295fc3b246b59cd2c8c4f9aa833ac351584882f7c23ac24f38ebc76213a23f8c84aeb8a2e7d46a504a3110775ad12f36b1fe1938cbad@YOUR_IP_2:30303")

3) Check peers using net.peerCount

0

For connecting peers on two different machines, the following approach worked for me:

1) As pointed out in many answers, ensure that the genesis file is exactly same on both nodes. You should get same difficulty, genesis, head and network values when admin.nodeInfo.protocols.eth is run on respective nodes

2) Go to the firewall settings (on Win machine: Control Panel>System and Security>Windows Firewall> Advanced Setting) and disable all rules related to geth in Inbound Rules option

3) While starting geth instance, use port 30303 only on both machines. Didn't work for me when I tried with other port numbers. Might be because when I looked at Outbound Rules in Firewall Settings, I found 30303 listed as allowed port for TCP/UDP against geth.Feel free to check the same in your machine(s) and modify the port# accordingly

4) Use admin.addPeer({enode}) to add peers. Details of {enode} can be taken from the other answer.

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.