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

Not able to dial peers behind NAT #1385

Closed
zeroxbt opened this issue Sep 21, 2022 · 2 comments
Closed

Not able to dial peers behind NAT #1385

zeroxbt opened this issue Sep 21, 2022 · 2 comments
Assignees
Labels
need/author-input Needs input from the original author

Comments

@zeroxbt
Copy link
Contributor

zeroxbt commented Sep 21, 2022

  • Version: 0.38
  • Platform: Linux 5.4.0-1029-aws 30-Ubuntu SMP Tue Oct 20 10:06:38 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

  • Subsystem: Nat manager

Severity:

High

Description:

After updating libp2p to the latest version we are experiencing issues where peers are not able to dial other peers that are behind NAT. These peers are found in our node's lan routing table, but not in its wan routing table since our node doesn't know about their public multiaddresses. We've tried to log these nodes' multiaddresses on startup and they only show the private ones.

An example of multiaddresses from dialable peer :
multiAddresses: [
'/ip4/127.0.0.1/tcp/9000/p2p/QmPvyWigki2QPz871ZjRb7z9EzpnXZQRJSGnuDBtKkSXpD',
'/ip4/165./tcp/9000/p2p/QmPvyWigki2QPz871ZjRb7z9EzpnXZQRJSGnuDBtKkSXpD',
'/ip4/10.
/tcp/9000/p2p/QmPvyWigki2QPz871ZjRb7z9EzpnXZQRJSGnuDBtKkSXpD',
'/ip4/10.***/tcp/9000/p2p/QmPvyWigki2QPz871ZjRb7z9EzpnXZQRJSGnuDBtKkSXpD'
]

An example of the multiaddresses from peer that is not dialable :
multiAddresses: [
'/ip4/127.0.0.1/tcp/9000/p2p/QmS78vHFNSvGhx2Fn7kzXW8y7riZViUcx4J8nByJYLPdXu',
'/ip4/172.***/tcp/9000/p2p/QmS78vHFNSvGhx2Fn7kzXW8y7riZViUcx4J8nByJYLPdXu'
]

As you can see, the second peer's multiaddresses contain only the private ips.

After some investigation, we found that the ips are read from the object return by os.networkInterfactes() in the tcp module. This method doesn't return the public ip, so we've tried to hardcode it there and that makes the peer dialable.

Config object :
Screenshot 2022-09-21 at 10 37 56

Previously used versions :
  • "libp2p": "^0.32.4",
  • "peer-id": "^0.15.3",
  • "libp2p-bootstrap": "^0.13.0",
  • "libp2p-kad-dht": "^0.24.2",
  • "libp2p-mplex": "^0.10.7",
  • "libp2p-noise": "^4.0.0",
  • "libp2p-record": "^0.10.5",
  • "libp2p-tcp": "^0.17.2",
  • "it-length-prefixed": "^5.0.3"
Currently used versions:
  • "libp2p": "^0.38.0",
  • "@libp2p/bootstrap": "^2.0.0",
  • "@libp2p/crypto": "^1.0.4",
  • "@libp2p/kad-dht": "^3.0.4",
  • "@libp2p/mplex": "^5.0.0",
  • "@libp2p/peer-id-factory": "^1.0.18",
  • "@libp2p/tcp": "^3.0.3",
  • "it-length-prefixed": "^8.0.2"

Steps to reproduce the error:

@zeroxbt zeroxbt added the need/triage Needs initial labeling and prioritization label Sep 21, 2022
@p-shahi
Copy link
Member

p-shahi commented Sep 27, 2022

In discussion with @achingbrain , we think this is because you have not added your public IP as an announce address. The relevant documentation: https://github.com/libp2p/js-libp2p/blob/master/doc/CONFIGURATION.md#customizing-libp2p

Until we ship AutoNAT, you'll need to add the address as specified. That should resolve your issue.

@BigLep BigLep added need/author-input Needs input from the original author and removed need/triage Needs initial labeling and prioritization labels Sep 28, 2022
@zeroxbt
Copy link
Contributor Author

zeroxbt commented Sep 29, 2022

Hi @p-shahi, thanks for the response. I've just tested your solution and everything is now working as expected.

@zeroxbt zeroxbt closed this as completed Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/author-input Needs input from the original author
Projects
None yet
Development

No branches or pull requests

4 participants