Skip to content

Commit 30a9386

Browse files
authored
Merge pull request #9 from n0-computer/rae/docs-review2
add ip privacy section
2 parents 70f8ef7 + f5e6ead commit 30a9386

File tree

2 files changed

+111
-24
lines changed

2 files changed

+111
-24
lines changed

concepts/holepunching.mdx

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
title: "Holepunching"
33
---
44

5-
When two devices want to connect directly over the internet, they face a common problem: **Network Address Translation (NAT)**. Most home and office networks use NAT, which acts like a one-way door—devices inside the network can reach out to the internet, but the internet can't easily reach back in.
5+
With holepunching, iroh applications can:
6+
- **Connect directly** between devices without manual network configuration
7+
- **Reduce latency** by avoiding servers when possible
8+
- **Save bandwidth** by keeping data transfer peer-to-peer
9+
- **Improve resilience and reliability** by not depending on all traffic being sent through third parties
10+
11+
The best part? All of this happens automatically—you don't need to understand the technical details to benefit from it.
612

713
## The Problem: NAT Blocks Direct Connections
814

@@ -13,19 +19,37 @@ something you requested. The combination of NAT (which translates addresses) and
1319
firewall rules (which filter traffic) makes direct connections
1420
challenging.
1521

22+
Most home and office networks use NAT, which acts like a one-way door—devices
23+
inside the network can reach out to the internet, but the internet can't easily
24+
reach back in. This causes reliance on central servers, which can introduce
25+
latency and reliability issues.
26+
1627
Traditionally, this problem was solved by:
1728
- **Port forwarding**: Manually configuring your router to allow specific connections (tedious and requires technical knowledge)
1829
- **Relay servers**: Routing all traffic through a third-party server (slow and expensive)
1930

31+
2032
## The Innovation: Holepunching
2133

2234
**Holepunching** is a clever technique that works around NAT and firewall restrictions to allow direct connections between peers without manual configuration or relying entirely on relay servers.
2335

24-
Here's how it works:
36+
iroh uses a sophisticated holepunching implementation built on top of QUIC and integrates with the relay system. The process relies on two key elements:
37+
38+
Holepunching works in most network configurations, but some corporate firewalls or cellular networks may still require relay fallback. iroh handles this automatically.
39+
40+
41+
## How Holepunching Works in iroh
2542

2643
### 1. Initial Contact Through a Relay
2744

28-
Both peers first connect to a shared [relay server](/concepts/relays). The relay acts as a meeting point where peers can coordinate without being able to connect directly yet.
45+
Both peers first connect to a shared [relay server](/concepts/relays). The relay
46+
acts as a meeting point where peers can coordinate without being able to connect
47+
directly yet.
48+
49+
The relay server observes each node's public IP address and port (the address
50+
from which it sees incoming traffic). This *reflective address* can be used by
51+
the remote peer to reach through the firewall, provided the firewall considers
52+
it expected traffic.
2953

3054
### 2. Sharing Connection Information
3155

@@ -34,6 +58,18 @@ Through the relay, peers exchange their:
3458
- **Port numbers** (the specific door number the router assigned them)
3559
- **Local addresses** (in case they're on the same network)
3660

61+
Nodes coordinate their holepunching attempts through the relay as a side
62+
channel. Both nodes simultaneously send UDP datagrams to each other's reflective
63+
addresses. Since both are sending on the same 4-tuple (source IP, source port,
64+
destination IP, destination port), the firewalls recognize the incoming packets
65+
as matching outbound traffic and allow them through.
66+
67+
Importantly, the relay server doesn't actively participate in holepunching -- it
68+
simply forwards encrypted packets between nodes without knowledge of whether
69+
they contain application data or coordination messages.
70+
71+
72+
3773
### 3. Simultaneous Outbound Connection
3874

3975
Here's the magic: both peers try to connect to each other **at the same time**. When peer A sends a packet to peer B's public address, A's NAT creates a mapping and the firewall creates a temporary rule allowing responses from B. When peer B sends a packet to peer A at the same moment, B's NAT and firewall do the same.
@@ -44,25 +80,12 @@ Because both NAT mappings are established and both firewalls now have rules expe
4480

4581
If holepunching fails (some networks use particularly strict NAT configurations), iroh automatically falls back to routing traffic through the relay server. This ensures connections always work, even if they can't be direct.
4682

47-
## Why This Matters
48-
49-
With holepunching, iroh applications can:
50-
- **Connect directly** between devices without manual network configuration
51-
- **Reduce latency** by avoiding relay servers when possible
52-
- **Save bandwidth** by keeping data transfer peer-to-peer
53-
- **Maintain privacy** by not routing all traffic through third parties
54-
55-
The best part? All of this happens automatically—you don't need to understand the technical details to benefit from it.
56-
57-
## How iroh Implements Holepunching
83+
## Read more
5884

59-
iroh uses a sophisticated holepunching implementation built on top of QUIC and integrates with the relay system. For technical details on the implementation, see:
85+
For technical details on the implementation, see:
6086

6187
- [iroh's holepunching implementation](https://docs.rs/iroh/latest/iroh/endpoint/index.html#nat-traversal)
6288
- [Relay system documentation](/concepts/relays)
6389
- [Dedicated infrastructure setup](/deployment/dedicated-infrastructure)
6490
- [Endpoint configuration](https://docs.rs/iroh/latest/iroh/endpoint/struct.Endpoint.html)
6591

66-
<Note>
67-
Holepunching works in most network configurations, but some corporate firewalls or cellular networks may still require relay fallback. iroh handles this automatically.
68-
</Note>

deployment/security-privacy.mdx

Lines changed: 70 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ iroh is designed with security and privacy as core principles. This document
66
outlines the key security and privacy features of iroh, as well as best
77
practices for deploying and using iroh in a secure manner.
88

9-
## End-to-End Encryption
9+
## Data Privacy with End-to-End Encryption
1010

1111
All data transmitted between iroh endpoints is protected with end-to-end
1212
encryption. This means that data is encrypted on the sender's device and can only
@@ -23,11 +23,12 @@ endpoint creation.
2323

2424
## Public Relays
2525

26-
All traffic sent through the public relays is end-to-end encrypted. The relays
27-
are not able to read any of the traffic that they forward or help connect.
28-
However, the relays are able to see metadata about connections, such as source
29-
and destination IP addresses, connection times, and the amount of data
30-
transferred.
26+
iroh is by default configured to use shared public infrastructure that is
27+
operated by [the n0 team](https://n0.computer/). Because traffic is end-to-end
28+
encrypted, relays are not able to read any of the traffic that they forward or
29+
help connect. However, the relays are able to see metadata about connections,
30+
such as source and destination IP addresses, connection times, and the amount of
31+
relayed data.
3132

3233
We recommend that you do not use the public relays for sensitive or confidential
3334
data. If you need more control over your relay infrastructure, we recommend that
@@ -36,3 +37,66 @@ you use [dedicated infrastructure](/deployment/dedicated-infrastructure) for pro
3637
We monitor the public relays for abuse and malicious activity. If we detect
3738
abuse, we reserve the right to block offending IP addresses or users from
3839
accessing the public relays.
40+
41+
42+
## Protecting leakage of IP Addresses
43+
44+
Any direct connection between two devices stands a high chance of being the fastest
45+
connection, but always requires IP addresses to be disclosed. As with the majority
46+
of the deployed internet stack today, when two endpoints establish a direct
47+
connection, they expose and exchange their IP addresses to each other.
48+
49+
IP address privacy considerations are primarily relevant for consumer or peer-to-peer applications
50+
where strangers or untrusted parties connect directly over the internet. In these
51+
scenarios, developers cannot guarantee anonymity or trust between endpoints, and
52+
exposing IP addresses can lead to privacy risks such as location tracking or
53+
targeted attacks.
54+
55+
To mitigate these risks, we recommend the following strategies to protect IP
56+
address privacy when using iroh, depending on your specific use case and threat model:
57+
58+
### Basic Protection: Use dedicated infrastructure
59+
60+
If you own the infrastructure, run your own DNS server, and
61+
manage the devices connecting to your network, you have control over the network
62+
topology and can implement appropriate security measures. We do not recommend using
63+
public relays for production systems, as this is shared public
64+
infrastructure that has no guarantees around privacy or uptime.
65+
66+
We recommend reviewing our [dedicated
67+
infrastructure](/deployment/dedicated-infrastructure) guidance to set up relay
68+
and DNS infrastructure that fits your needs.
69+
70+
### More protection: Use Tor or Similar Onion Routing
71+
72+
Services like Tor provide onion routing, which encrypts packet metadata for each
73+
relay in the route. This offers strong IP privacy guarantees through multi-hop
74+
routing with layered encryption.
75+
76+
### Upcoming
77+
78+
#### Relay-Only Mode
79+
80+
Upcoming releases of iroh will support disabling hole-punching to send all traffic
81+
exclusively through relays. This provides IP privacy with some important caveats:
82+
83+
- **Single-hop routing**: Traffic passes through one relay, not multiple hops
84+
- **Trust required**: The relay operator can technically see which endpoints are
85+
communicating and their IP addresses
86+
- **Data remains encrypted**: The relay cannot read the actual content due to
87+
end-to-end encryption
88+
89+
This mode is suitable when you trust your relay infrastructure but still want to
90+
avoid direct IP exposure between endpoints.
91+
92+
#### Multi-Hop Relay Routing
93+
94+
We've explored the possibility of adding multi-hop relay routing to iroh. While
95+
technically feasible, this feature is not currently on the near-term roadmap.
96+
97+
It's important to note that even with multi-hop relay routing, this would not be
98+
equivalent to onion routing. True onion routing requires encrypting packet metadata
99+
for each relay in the route, which would require significant protocol changes.
100+
101+
If these features are interesting to you, please [contact us](https://n0.computer/)
102+
to discuss your specific requirements.

0 commit comments

Comments
 (0)