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

How can I use libp2p simply for NAT traversal? #1861

Closed
actuday6418 opened this issue Nov 26, 2020 · 8 comments
Closed

How can I use libp2p simply for NAT traversal? #1861

actuday6418 opened this issue Nov 26, 2020 · 8 comments

Comments

@actuday6418
Copy link

Disclaimer: I don't have an education in networking, so please forgive my naivety.

Hey,
I want to send data over the internet from one computer behind a router to another also behind a router. I don't need this data to be encrypted or anything. I don't need the computers to discover each other either.

The way I understand it, NAT works by forwarding traffic from the router's public address to a device's private one. If there is a way for the router to know that the incoming data must go to a particular node in it's private network, shouldn't there be some way of identifying to which node within a private network a data packet must go? So then the data packet will have some identifying characteristic ( address, port? ). Can I determine this address and then use that to send data from one computer to another?

@mxinden
Copy link
Member

mxinden commented Nov 26, 2020

Hi @actuday6418,

I think the concept of NAT is too complex to summarize in a single Github issue. As a first introduction I would propose reading through the Wiki article. As rust-libp2p uses TCP as its underlying transport protocol the TCP hole punching article might be of some help as well.

Today rust-libp2p does not offer any NAT traversal strategies. You can follow current efforts on #1722.

In case you control the routers in front of both machines you might be able to open and forward specific ports from those routers to your machines. For details see the port forwarding article.

@actuday6418
Copy link
Author

@mxinden Unfortunately, I don't control the routers. What I said originally was a simplified version of the truth. My ISP has got NAT too other than that in my router (router's WAN address was different from my public address). So port forwarding won't help.

I'll definitely look into TCP hole punching. Thanks for the info. As an afterthought, does

Today rust-libp2p does not offer any NAT traversal strategies

mean there is no way for two peers behind NAT not controlled by them to communicate using libp2p? Or is that specific to the Rust implementation?

@mxinden
Copy link
Member

mxinden commented Nov 30, 2020

mean there is no way for two peers behind NAT not controlled by them to communicate using libp2p? Or is that specific to the Rust implementation?

This is specific to the Rust implementation, which does not support NAT traversal yet. Take a look at the general libp2p docs to find out more about other implementations.

@romanb
Copy link
Contributor

romanb commented Nov 30, 2020

This is specific to the Rust implementation, which does not support NAT traversal yet.

I don't think (TCP) hole punching works with any libp2p implementation beyond very simple cases of NAT (libp2p/specs#196). Related discussions include #1690 (comment) and #1563.

@romanb
Copy link
Contributor

romanb commented Mar 2, 2021

There is a recent effort to revive the libp2p relay protocol (#1838), which is practically speaking the option for NAT traversal that has the highest chance of success in many network setups. As alluded to earlier, sophisticated hole punching techniques that function without intermediate relays are not really possible with rust-libp2p at this time. I'm considering this question answered, but feel free to open new specific issues or new discussions.

@romanb romanb closed this as completed Mar 2, 2021
@lukebelbina
Copy link

There is a recent effort to revive the libp2p relay protocol (#1838), which is practically speaking the option for NAT traversal that has the highest chance of success in many network setups. As alluded to earlier, sophisticated hole punching techniques that function without intermediate relays are not really possible with rust-libp2p at this time. I'm considering this question answered, but feel free to open new specific issues or new discussions.

Out of curiosity is there a link to a discussion on why this is not possible in rust? Is it a language issue (it would be possible in other languages) or an architectural issue?

@mxinden
Copy link
Member

mxinden commented Apr 1, 2021

There is a recent effort to revive the libp2p relay protocol (#1838), which is practically speaking the option for NAT traversal that has the highest chance of success in many network setups. As alluded to earlier, sophisticated hole punching techniques that function without intermediate relays are not really possible with rust-libp2p at this time. I'm considering this question answered, but feel free to open new specific issues or new discussions.

Out of curiosity is there a link to a discussion on why this is not possible in rust? Is it a language issue (it would be possible in other languages) or an architectural issue?

@lukebelbina the important bit is "with rust-libp2p at this time". NAT hole punching is currently under development for go-libp2p (see https://github.com/protocol/web3-dev-team/pull/21/files) and will eventually make it into rust-libp2p as well. As always, help would be appreciated.

@mxinden
Copy link
Member

mxinden commented Jun 25, 2021

Following up here for future readers: Progress is tracked in #2052.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants