I have found an easy solution to make your private network isolated. It does not prevent UDP packet flow, but it does prevent incoming TCP connections. The solution is to change the discovery protocol constants for packet types, so the other network would not understand you. You just have to modify this line of code in p2p/discover/udp.go:
pingPacket = iota + 1 // zero is 'reserved'
adding a constant that is larger than 4, for example:
// RPC packet types
const (
pingPacket = iota + 64
pongPacket
findnodePacket
neighborsPacket
)
The result is this:
DEBUG[10-23|20:05:32] Bad discv4 packet addr=34.236.33.177:30303 err="unknown type: 1"
DEBUG[10-23|20:05:32] Bad discv4 packet addr=212.170.201.113:30399 err="unknown type: 1"
DEBUG[10-23|20:05:32] Bad discv4 packet addr=41.182.132.197:30399 err="unknown type: 1"
DEBUG[10-23|20:05:33] Bad discv4 packet addr=94.63.228.3:30399 err="unknown type: 1"
DEBUG[10-23|20:05:33] Bad discv4 packet addr=77.221.88.207:30303 err="unknown type: 1"
DEBUG[10-23|20:05:34] Bad discv4 packet addr=86.174.184.92:30399 err="unknown type: 1"
DEBUG[10-23|20:05:34] Bad discv4 packet addr=97.91.252.163:30399 err="unknown type: 1"
DEBUG[10-23|20:05:34] Bad discv4 packet addr=84.237.99.182:2931 err="unknown type: 1"
Since the rule is to receive a PONG from a PING before connecting, the dialing nodes never get a PONG and the discovery mechanism fails. It only works with your own nodes.
--bootnodesflag... :-) – Richard Horrocks Oct 22 '17 at 21:01gethclient is connected to the bootnode and everything is working ok. But I can see lots of PING/PONG in the log from hundreds of unknown IP addresses. I don't think someone even knows my bootnode IP because my net is not yet public, so this is not the case. I think there is some problem with the discovery mechanism that creates a lot of unnecessary traffic when you use private net. – Nulik Oct 22 '17 at 21:27params/bootnodes.go, removed all hardcoded bootnodes and put my own. But despite that I still can see weird traffic in the console. This is how I did it: https://ethereum.stackexchange.com/questions/28007/disabled-private-network-is-still-discovering-nodes – Nulik Oct 22 '17 at 21:44datadirdirectory - did that include removing~/.ethereum/geth/nodes/? (Which is an.ldbdatabase of known nodes?) Could be you had old, discovered nodes in there? – Richard Horrocks Oct 22 '17 at 21:51datadirand I was using my owndatadirI didn't remove it because it shouldn't be accessed bygeth. But I did a fresh install on a server , rangethfor the first time, and it is still displaying traffic which shouldn't happen. – Nulik Oct 22 '17 at 22:00bin/bootnodealso gets traffic, not onlygeth– Nulik Oct 22 '17 at 22:33gethcompiled with nonexistent bootnodes and it was showing connection refused error, no traffic. However as soon as replaced the binary with good bootnodes, the traffic jumped to very high rate, impossible to see the console. Somehow my blockchain database was poisoned with IP addresses from Ethereum's mainnet and now I can't get rid of them. They are replicating like viruses on each new node I am adding in my private net. – Nulik Oct 22 '17 at 23:15--nodiscoveroption but it is too late. Now my IP address is known by nodes in Ethereum main net and they are trying to connect with me but my node says "Failed RLPx hanshake". I think this issue may only be fixed if we add networkid to theenodeurl. This is the only way to avoid collisions between networks. – Nulik Oct 23 '17 at 00:55