Search code examples
network-programmingp2pbittorrent

Connect to a peer inside a Carrier-based NAT(and a home NAT) from outside?


Are there any ways to establish a p2p connections among peers behind Carrier-grade NATs? Do I have to use a middle server to initiate the connection? Are there any other ways? How BitTorrent do establish a p2p connection in such a situation?


Solution

  • Do I have to use a middle server to initiate the connection?

    You don't need a server, any mutually reachable peer in a p2p network can act as rendezvous.

    Are there any ways to establish a p2p connections among peers behind Carrier-grade NATs?

    If the CGNAT uses Endpoint-Independent Mappings (EIM) as suggested by RFC 6888 and others then regular NAT traversal techniques apply.

    Are there any other ways?

    Some home routers support nat-pmp/pcp and forward that to the cgnat.

    How BitTorrent do establish a p2p connection in such a situation?

    See my answer on How NAT traversal works in case of peer to peer protocols like bittorrent.