From What is the Difference Between 127.0.0.1 and 0.0.0.0?:
What is the Difference Between 127.0.0.1 and 0.0.0.0?
- 127.0.0.1 is the loopback address (also known as localhost).
- 0.0.0.0 is a non-routable meta-address used to designate an invalid, unknown, or non-applicable target (a ‘no particular address’ place holder).
In the context of a route entry, it usually means the default route.
In the context of servers, 0.0.0.0 means all IPv4 addresses on the local machine. If a host has two IP addresses, 192.168.1.1 and 10.1.2.1, and a server running on the host listens on 0.0.0.0, it will be reachable at both of those IPs.
What you want to do is to find the IP address of the machines that is non-127.0.0.1 which will look like on OS/X (and Linux):
Iota:~ bok$ ifconfig -a
inet 127.0.0.1 netmask 0xff000000
inet 192.168.0.11 netmask 0xffffff00 broadcast 192.168.0.255
On Windows, the equivalent command is
The 192.168.0.11 address is the one you want to use in your enode string as this is the IP address of the machine that is contactable by your the other computers on your network.
You will then need to add your peer using a command like:
Here's a step-by-step example of running 2 miners on the same computer under OS/X, with the miners communicating with each other. You should be able to replicate this in Windows and Linux. You should also be able to replicate this on more than 2 nodes, and on separate computers.
Update Oct 31 2016 00:00:56 UTC You may encounter a problem with the DAG generation as both miners will try to create the DAG at the same time in the same file. On OS/X (and Linux), the DAG file is stored in
$HOME/.ethash. This is the same problem as described in Private chain, two geth miner on the same machine, second miner throws "panic: ethash_full_new IO or memory error" . The workaround is to start the second miner after the first miner has completed creating the DAG - when the initial DAG needs to be created. A new DAG will need to be created periodically and this may cause one of your miners to crash.
geth version reports
- This example was created in the directory
/tmp/Test2Miners, with miner #1's data directory being
/tmp/Test2Miners/miner1data and miner #2's data directory being
I created the file
/tmp/Test2Miners/genesis.json with the following contents:
/tmp/Test2Miners/testpassword with the following contents:
/tmp/Test2Miners/initMiner1 with the following contents, then set the executable bit using the command
chmod 700 /tmp/Test2Miners/initMiner1:
geth --datadir /tmp/Test2Miners/miner1data init /tmp/Test2Miners/genesis.json
geth --datadir /tmp/Test2Miners/miner1data --password /tmp/Test2Miners/testpassword account new
/tmp/Test2Miners/initMiner2 with the following contents, then set the executable bit using the command
chmod 700 /tmp/Test2Miners/initMiner2:
geth --datadir /tmp/Test2Miners/miner2data init /tmp/Test2Miners/genesis.json
geth --datadir /tmp/Test2Miners/miner2data --password /tmp/Test2Miners/testpassword account new
/tmp/Test2Miners/runMiner1 with the following contents, then set the executable bit using the command
chmod 700 /tmp/Test2Miners/runMiner1:
geth --datadir /tmp/Test2Miners/miner1data --unlock 0 --password /tmp/Test2Miners/testpassword --mine --minerthreads 1 --port 30301 console
/tmp/Test2Miners/runMiner2 with the following contents, then set the executable bit using the command
chmod 700 /tmp/Test2Miners/runMiner2:
geth --datadir /tmp/Test2Miners/miner2data --unlock 0 --password /tmp/Test2Miners/testpassword --mine --minerthreads 1 --port 30302 console
I initialised the data directories and created the first account (coinbase) for both miners using the command:
In terminal window #1, I started miner #1 using the following command. I've included the enode information printed on the console, which can also be determined by using the
In terminal window #2, I started miner #2 using the command:
I've replaced the
[::] in the enode strings with the local IP address, so my
admin.addPeer(...) commands would look like:
I pasted the
admin.addPeer(...) with the enode string from the miner #1 into the miner#2 console.
In the miner #1 console:
caps: ["eth/62", "eth/63"],
And in the miner #2 console:
caps: ["eth/62", "eth/63"],
Here is the console log from one of the miners:
I1031 00:53:27.604563 miner/worker.go:435] 🔨 🔗 Mined 5 blocks back: block #1447
I1031 00:53:27.605050 miner/worker.go:539] commit new work on block 1453 with 0 txs & 0 uncles. Took 460.253µs
I1031 00:53:29.682117 core/blockchain.go:1001] imported 1 block(s) (0 queued 0 ignored) including 0 txs in 12.081834ms. #1453 [3a94659b / 3a94659b]
I1031 00:53:29.683526 miner/worker.go:539] commit new work on block 1454 with 0 txs & 0 uncles. Took 1.167337ms
I1031 00:53:29.683565 miner/worker.go:435] 🔨 🔗 Mined 5 blocks back: block #1448
The 3rd line shows that the other miner has mined a block, and this miner is importing the block. The other lines show that this miner is mining the blocks.
To automate the peer-to-peer discovery, I create
/tmp/Test2Miners/miner1data/static-nodes.json with the following information (reference
and I copy this file to
I restart both miners using the
/tmp/Test2Miners/runMiner2 commands in separate terminal windows and check that they are connected to each other using the
admin.peers and they are. Success++.