Skip to content

Not able to dial peers behind NAT #1385

Closed
@zeroxbt

Description

@zeroxbt
  • 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:

Metadata

Metadata

Assignees

Labels

need/author-inputNeeds input from the original author

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions