besu icon indicating copy to clipboard operation
besu copied to clipboard

`--netrestrict` feature to enable IP filtering for Besu nodes used in key infrastructure

Open non-fungible-nelson opened this issue 1 year ago • 4 comments
trafficstars

Description

As an infrastructure provider, I want to be able to restrict my node to certain IP networks so that I can prevent and filter unwanted peering. I also want parity with Geth nodes with this option to better take advantage of existing configs and tooling.

Besu should enable restriction to peer-to-peer connectivity on an IP subnet. Doing so will further isolate the network and prevents cross-connecting with other blockchain networks in case the nodes are reachable from the Internet.

Acceptance Criteria

  • --netrestrict option exposed taking a string representing IP value
  • No external peering or connection to the internet is enabled
  • If this option is set to a non-nil value, only hosts which match one of the IP networks contained in the list are considered.

Reference code

Geth Codebase

non-fungible-nelson avatar Feb 27 '24 17:02 non-fungible-nelson

Here is an example of how we configure geth:

netrestrict: "10.80.0.0/16"

FlorianHuc avatar Feb 28 '24 09:02 FlorianHuc

I've had a quick look at this. I assume that we want to support a list of comma separated CIDR strings (same as geth). In geth netrestrict is used for discovery and p2p, I assume we want to do the same. To implement this we need to create a new CLI option, parse the CIDR string (geth ignores additional commas and whitspace), and need to check whether the IP addresses are in the range.

pinges avatar Apr 08 '24 09:04 pinges

Thanks for the analysis. If we can have a feature following geth's specs, I indeed believe it's the best.

FlorianHuc avatar Apr 11 '24 15:04 FlorianHuc

For p2p we are using Netty. We can use a String to create an instance of the IpSubnetFilterRule class in Netty, which can be used in a ChannelInitializer, which can be used as a childHandler in the ServerBootstrap. For discovery we are using vertx DatagramSocket. Not sure how to use vertx to do the filtering for us, but we could do the filtering manually as well.

pinges avatar Apr 18 '24 00:04 pinges

Is this blocked due to our internal resourcing needs or another reason?

non-fungible-nelson avatar May 03 '24 14:05 non-fungible-nelson

@non-fungible-nelson It's blocked due to internal resourcing needs at the moment.

jframe avatar May 08 '24 03:05 jframe