Syllabus Lesson 102 of 156 · Packets, DNS and IP addresses
Packets, DNS and IP addresses

Relays and VPNs, honestly

Why it matters VPNs, Tor and two-hop relays are all sold as "privacy", and they protect very different things. The honest question to ask of any of them is: does any single party learn both who I am and where I go? You will build a small model that answers it for any route.

Lesson 86 compared life with and without a VPN. Here you go further and model several tools side by side.

Picture passing a note across a classroom. If you hand it to one friend who walks it to the recipient, that friend knows who sent it and who got it. If it goes through two friends, and the note is folded so the first only sees "pass to Bea" and the second only sees "give to Sol", neither friend knows both ends.

Relay: a server that receives your traffic and passes it on. Each relay sees where a packet came from (the hop before) and where it goes next (the hop after).

VPN: one relay, run by one company: it sees your IP address and the sites you reach.

Two-hop relay: two relays run by different companies. The first (ingress) sees your IP but only knows the next relay; the second (egress) sees the site but only knows the first relay. iCloud Private Relay is a well-known example.

Tor: a free network of volunteer relays. Your traffic goes through three: a guard, a middle and an exit, wrapped in layers of encryption (onion routing), so no single relay sees both ends. Leg 7 builds a circuit step by step.

The facts, dated

iCloud Private Relay (part of Apple's paid iCloud+ plan) covers browsing in Safari, DNS lookups, and some unencrypted traffic from apps (checked October 2026). Its second hop is run by partner content delivery networks (companies that run servers around the world to deliver websites quickly), not by Apple. It is not a full VPN: other browsers and most app traffic do not go through it.

A VPN usually covers everything your device sends, but the VPN company sees what your provider used to. Tor Browser sends its own traffic through Tor and also makes its users look alike, which matters for fingerprints (the next module, Network fingerprints).

The rules of the model

A route is a list of the parties between you and the website, ending with the website, for example ["vpn", "shopb.example"]. There is always also the "network": your Wi-Fi and provider, who carry your packets to the first hop. There are three facts anyone might learn: "your_ip", "site" (which website you visit) and "content" (what you read and send).

  • The network always sees your_ip. It sees the site only when you connect to the website directly (the route has just one entry), and the content only when, also, HTTPS is off.
  • The first relay sees your_ip, because packets arrive straight from you.
  • The last relay (the one just before the website) sees the site, because it must connect to it. Without HTTPS it also sees the content.
  • The website always sees site and content, and sees your_ip only when you connect directly.
  • A middle relay sees neither end.

A one-relay route (a VPN) makes the first and last relay the same, so it learns both. That is the whole point of this lesson, falling out of these few rules.

In Python, a set of facts can be written {"your_ip", "site"}, and an empty set is set() (not {}, which is an empty dict). enumerate(route) gives each position and name: for i, name in enumerate(route):.

In other languages

The core check, "does anyone know both ends?", in other languages:

// JavaScript
const linkers = view => Object.keys(view)
  .filter(p => view[p].has("your_ip") && view[p].has("site"))
  .sort();
// Rust
let mut linkers: Vec<&String> = view.iter()
    .filter(|(_, facts)| facts.contains("your_ip") && facts.contains("site"))
    .map(|(party, _)| party)
    .collect();
linkers.sort();
// C#
var linkers = view.Where(kv => kv.Value.Contains("your_ip") && kv.Value.Contains("site"))
                  .Select(kv => kv.Key).OrderBy(k => k).ToList();

A common misconception: "two hops means twice the encryption, so it is twice as safe". The gain is not more encryption; it is splitting knowledge between parties that do not share notes. If one company ran both hops, it would learn both ends again. And no relay stops cookies, logins or fingerprints.

Recap

  • A VPN is one relay: it learns both your IP and the sites you visit.
  • Two-hop relays and Tor split that knowledge so no single relay has both.
  • iCloud Private Relay covers Safari, DNS and some unencrypted app traffic; it is not a full VPN (checked October 2026).
  • None of these stops cookies, logins or fingerprinting.
Your turn

Model who learns what. Write three functions:

  1. who_learns(route, https=True): return a dict mapping "network" and every name in route to a set of the facts that party learns ("your_ip", "site", "content"), following the rules in the lesson. The last name in route is always the website.
  2. linkers(view): return a sorted list of the parties in view that learn both "your_ip" and "site".
  3. compare(setups, https=True): setups maps a name to a route; return a dict mapping each name to linkers(who_learns(route, https)).
The table printing is written for you. Tests try routes of every length with made-up names.

Spotted a problem in this lesson? Report it

Code · runs in your browser
Output