charon-distributed-validator-node icon indicating copy to clipboard operation
charon-distributed-validator-node copied to clipboard

Improve geth and lighthouse advertised public address configuration

Open corverroos opened this issue 2 years ago • 0 comments

🎯 Problem to be solved

The current configuration is not optimal for users behind a NAT that want to advertise a public address instead of relying on automatic peer discovery. See feedback from 0xFury on discord on how to configure externally advertised public addresses for geth and lighthouse.

https://discord.com/channels/849256203614945310/946519880910385172/1078776267194777810.

Proposed Solution:

  1. Geth supports external advertised address --nat=extip:<IP> for IP and --port=<PORT> for port:
  --nat value                         NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>) (default: "any")
  --port value                        Network listening port (default: 30303)

This can be configured in the docker-compose as (see .emv sample below):

command:
      --nat=${GETH_NAT:-any}
      --port=${GETH_PORT_P2P:-30303}

ports:
      - ${GETH_PORT_P2P:-30303}:${GETH_PORT_P2P:-30303}/tcp # P2P TCP
      - ${GETH_PORT_P2P:-30303}:${GETH_PORT_P2P:-30303}/udp # P2P UDP
  1. Lighthouse also supports advertised IPs and ports via the following command line args:
      --enr-address=${PUBLIC_IP:-}
      --enr-tcp-port=${LIGHTHOUSE_PORT_P2P:-}
      --enr-udp-port=${LIGHTHOUSE_PORT_P2P:-}

Example .env.sample:

######### Advanced Networking #########

# These are some parameters you can use to help with (incoming) peering issues on clients.
# One prerequisite to these tweaks is to ensure you open up the correct ports in your firewall/router.
# Another prerequisite is to declare your external public IP here:
#PUBLIC_IP=<external public IP>

# Enable NAT for Geth
# For additional NAT settings, see Geth docs: https://geth.ethereum.org/docs/fundamentals/command-line-options
#GETH_NAT=extip:${PUBLIC_IP}

Note we should alignPUBLIC_IP with CHARON_P2P_EXTERNAL_HOSTNAME and NIMBUS_EXTERNAL_IP, preferably use the same variable for all. Need to double check if all flags support IPs and DNSs or not...

corverroos avatar Feb 27 '23 12:02 corverroos