reth icon indicating copy to clipboard operation
reth copied to clipboard

Broadcast external IP from NAT in enode record

Open cody-wang-cb opened this issue 1 year ago • 26 comments

In our set up, we are running some op-reth nodes in non-discovery mode and running them in non-host docker image, and peering the nodes manually. By default, in non-discovery mode reth uses 127.0.0.1 as the enode ip, but we want to set the ip in the enode url using its host ip so that other internal nodes can still connect to it.

We tried with --addr but it didn't work. Seems like it was because it'd result in the server to listen to the ip directly, which we cannot do since we are running it on a non-host docker image, thus we prefer to just broadcast the host ip rather than directly setting it.

In geth, --nat:extip has worked for us. However, we tried using --nat:extip in reth which didn't work. Looking at the code it looks like it's only set in the discv4 but we have discovery mode turned off.

Thus proposing a fix to support this scenario by passing --nat info into the NetworkHandle, so that when local_node_record() is called, it would still try to fetch for external ip if there's any in non-discovery mode, rather than just the local ip for the enode.

Also based on suggestions, added functionality such that if disable-discovery is on, nat should also be disabled, and added disable-nat as well.

cody-wang-cb avatar Aug 12 '24 20:08 cody-wang-cb