Hole punching
lastmod 2024-05-31created 2015-03-2619 edits
Hole punching (or sometimes punch-through) is a technique in computer networking for establishing a direct connection between two parties in which one or both are behind firewalls or behind routers that use network address translation (NAT). To punch a hole, each client connects to an unrestricted third-party server that temporarily stores external and internal address and port information for each client. The server then relays each client's information to the other, and using that information each client tries to establish direct connection; as a result of the connections using valid port numbers, restrictive firewalls or routers accept and forward the incoming packets on each side.
Hole punching does not require any knowledge of the network topology to function. ICMP hole punching, UDP hole punching and TCP hole punching respectively use Internet Control Message, User Datagram and Transmission Control Protocols.
Introduction to NAT traversal techniques (RFC 5128)
- P2P and NAT: Introduction to NAT traversal techniques (RFC 5128) - Part 1: Relaying & Connection Reversal | NETMANIAS
- P2P and NAT: Introduction to NAT traversal techniques (RFC 5128) - Part 2: UDP Hole Punching | NETMANIAS
NAT Traversal
Relaying
When ClientA and ClientB communicate, they may in some cases be placed under NAT (Network Address Translation). In this approach, a relay server is set up to relay their communication, and they communicate through the server. They can keep exchanging data as long as the connection is valid, but this wastes unnecessary bandwidth and consumes server resources.
Connection Reversal
When one client is behind a NAT and B tries to connect to A, connecting to A's private IP is of course impossible, and connecting to the NAT's public IP observed by server S is also impossible because the NAT only allows connections going out from A. So the relay server S is used to tell server S the public IP of B, and then A, in reverse, attempts to connect and establish the connection.
TCP Hole punching
UDP Hole punching
This is the case where both clients are each behind their own NAT. This case is further divided depending on whether the two clients are behind the same NAT or behind different NATs.
See also
- P2P
- NAT
- TCP/UDP
- Port Control Protocol (PCP)
- NAT Port Mapping Protocol (NAT-PMP)
- Internet Gateway Device Protocol (UPnP IGD)
- Port knocking
- Korean: 세션 개시 프로토콜 (Session Initiation Protocol; SIP)
- STUN
Favorite site
- [Recommended] (Scrap) About hole punching technology 1
References
-
About_hole_punching_technology.pdf ↩