Different outgoing and incoming IPs?

Hi all, does libp2p work okay behind separated incoming and outgoing IPs? i.e. the outgoing IP of the server is different to the incoming IP, and requests coming back into the outgoing IP won’t make it to the server.

How do I advertise a different incoming IP with my outgoing connections.

I’m using the Go lib.

Yes it is.
Just be sure to use address announces to correctly announce your ingoing IPs.

Thanks! What’s the appropriate way to do this when using go-libp2p? Is the way to do it to specify the IP in the host address when creating the host.Host?

If I do that, when one host connects out to another peer does it automatically announce to that other peer the IP to connect back on of it wants to do that in the future?

I might not have been clear enough.

This is already something you do if you use libp2p.
Lookup any examples. And use that.

Multiple IP setups are very wide spread, almost all computers have at least a loopback, giving them 2 IPs, so it’s very well supported by almost all softwares (including linux and libp2p).

I assume you’ll allow packets on established connections back to the outgoing IP, right? Otherwise nothing will work.

But yeah, you can announce inbound addresses and use different outbound addresses. You need to pass an AddressFactory (libp2p package - github.com/libp2p/go-libp2p - pkg.go.dev). It’s a function that takes a list of addresses libp2p thinks you should announce, and returns a list of addresses you want to announce.

1 Like