ZcashFoundation / zebra

Zcash - Financial Privacy in Rust 🦓
https://zfnd.org/zebra/
Apache License 2.0
413 stars 106 forks source link

Zebra should support separate local bind and external advertise addresses #1890

Closed teor2345 closed 6 months ago

teor2345 commented 3 years ago

Is your feature request related to a problem? Please describe.

Currently, Zebra binds to the configured listen_addr, and also advertises that address to peers for inbound connections.

This doesn't work for nodes which bind to an internal address, but receive inbound connections on a different external address. (For example, NAT and firewalls.)

These nodes won't get inbound connections, because other nodes don't know their inbound addresses.

Describe the solution you'd like

Zebra should:

Describe alternatives you've considered

We could just support a single external address, but that makes dual-stack IPv4/IPv6 impossible. We could support multiple listener addresses.

teor2345 commented 2 years ago

We can re-open this if users ask for it.

upbqdn commented 1 year ago

I, as a random Zebra user, am interested in having this functionality. I could run Zebra at home on a private IP, redirect its traffic through a $5 VPS (which I already pay for) with a public IP, and accept inbound connections.

teor2345 commented 1 year ago

I, as a random Zebra user, am interested in having this functionality. I could run Zebra at home on a private IP, redirect its traffic through a 5$ VPS (that I already pay for) with a public IP, and accept inbound connections.

I just discovered a workaround for this: Run 2 Zebra instances:

  1. Port forward your external IP to the first instance
  2. Add your external IP (or dynamic DNS name) to the initial_mainnet_peers list for the second instance, along with the default DNS seeders

Then the second instance will connect to the first instance via your external IP, and gossip its IP address.

Other Zebra instances will also auto-detect the external IPs of instances with 0.0.0.0 in their version messages. So if you're using the default Zcash port externally, and listening on 0.0.0.0 internally, your IP might already be gossiped on the network.

teor2345 commented 1 year ago

I'm going to re-open this, because it would have been really useful to have for the final release candidate testing.

emersonian commented 6 months ago

+1, all of our instances are behind load balancers and cannot yet contribute to the P2P network.

mpguerra commented 6 months ago

I've scheduled this for next sprint (Sprint 10) let's see if we can tackle this then

oxarbitrage commented 6 months ago

We could just support a single external address, but that makes dual-stack IPv4/IPv6 impossible.

I think is a lot easier to do a single external address as having multiple address will require negotiate with each one of them.

@emersonian in your case, will a single address make it ?

emersonian commented 6 months ago

A single address is fine with me, thanks for looking into this.

For the backlog: it would be amazing if Zebra could auto-discover its public IP address(es) as a configuration option some day, saving me an initContainer step when rolling out deployments.

oxarbitrage commented 6 months ago

A single address is fine with me, thanks for looking into this.

Ok, lets do this for now as my first impression is telling me it will be a lot easier.

For the backlog: it would be amazing if Zebra could auto-discover its public IP address(es) as a configuration option some day, saving me an initContainer step when rolling out deployments.

We had an issue for this (https://github.com/ZcashFoundation/zebra/issues/1893) but it was closed as not planned. @mpguerra do you think we should reopen it ?