Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Autonat manager should test the public IP with the tcp/udp listen ports #789

Open
hsanjuan opened this issue Feb 7, 2020 · 5 comments
Labels
kind/enhancement A net-new feature or improvement to an existing feature

Comments

@hsanjuan
Copy link
Contributor

hsanjuan commented Feb 7, 2020

Opening based on the memory of a convo with @Stebalien a couple of weeks ago.

Currently running a libp2p host on "/ip4/0.0.0.0/tcp/4001" inside a NAT with Autonat enabled does not automatically detect that the router port may have been manually open. The "/ip4/public_address/tcp/4001" addressed is becomes only part of the current host Addresses only after it has received several successful connections to it, however, since it is never among the official addresses provided on dhts or exchanged in Identify, that is unlikely to happen.

For the history of p2p (eMule, Bittorrent, some multiplayer games...), users have simply gone and opened the necessary ports on the routers, rather than relying on upnp etc.. However libp2p autonat components do not check at all if the peers are reachable on the public IP+default listen port, which is actually likely.

What is also very easy is to tell users with NAT problems that they should just open port 4001 in their routers and things will work. We cannot tell them this at the moment and that sucks for them and for us.

The current workaround is to manually set the announce addresses, but that prevents the parts of the address-autodiscovery that work (i.e. LAN interfaces etc).

@hsanjuan hsanjuan added the kind/enhancement A net-new feature or improvement to an existing feature label Feb 7, 2020
@Stebalien
Copy link
Member

https://github.com/libp2p/go-libp2p-autonat-svc/issues/34 (but your issue is better)

@godcong
Copy link
Contributor

godcong commented Aug 26, 2020

You cannot access the open port 4001 under non-public network nodes.
TCP Hole Punching needs bind a nat mapping port to your local address.
Example:

  YourPC(192.168.1.2:4001) -> Router(10.250.x.x:#a random mapping port#) -> ISP(forward to internet) -> Internet(183.193.57.91:#random#)

If other pc want to connect your pc.
he can dial with the source port + ip with Internet(183.193.57.91:#random#)
then the isp will forward the message to your Router(10.250.x.x:#a random mapping port#)
if not mapping the isp will forward the message to your Router(10.250.x.x:4001)

So this should only be detected when the Router or YourPC is on the public network
In addition, libp2p does not seem to assign the NAT port bind to the local port.

@abing258
Copy link

ipfs id
Addresses has no public IP and port. I use image: 'IPFs / go IPFs: v0.10.0'

Now, besides setting announcement, are there any other methods that can be added actively? I don't want to give up address autodiscovery

@Artoria2e5
Copy link

Artoria2e5 commented Apr 9, 2023

Reproducing ipfs/kubo#7621 here. I got the port forwarding set on the router, but libp2p made up its own. Not a big deal except for, well, the fact that it's random (so people can't remember my node or something) when I got a perfectly fixed one. upnpc -l gives the expected 60-second lease from libp2p.

Announce somehow figured out the manually set 4001 UDP, but not the 4001 and 4002 TCP. Bummer.

Oh and I don't have a static public ip nor do I have DDNS.

@marten-seemann
Copy link
Contributor

@Artoria2e5 This will be fixed soon (in a couple of months). The team is now working on a new address pipeline (#2229), which will include AutoNAT v2 (libp2p/specs#503).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A net-new feature or improvement to an existing feature
Projects
None yet
Development

No branches or pull requests

7 participants