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.
--bootnodes
flag... :-)geth
client 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.