One café, one purchase, in four stages: DNS, the TCP handshake, TLS and the request. Then where the VPN wraps each packet and who sees what. Part 1 of 3.
- Date
- Reading
- 9 min read
- Written by
- Nick Li
- Tags
- #Engineering#Risk
Ask ten people what a VPN does and most will say "it hides my IP" or "it encrypts everything". Both are half right. This article follows one ordinary web request, with and without a VPN, step by step, so you can see what is sealed, what is still visible, and at which point the VPN wraps it. It's the first of three: the next two cover what your VPN provider can see, and how to use your VPN account on a router or with your own software.
The example: a coffee shop in Causeway Bay
You're on the café's free Wi-Fi and you open shop.example.hk to buy something. The request travels this path:
Your laptop ──── cafe Wi-Fi ──── cafe router ──── ISP ──── internet ──── shop.example.hk
(you) (anyone nearby) (the cafe) (PCCW, HKBN…) (the shop)
Everyone on that line can look at the packets passing through. What they can read depends on which stage the conversation is at. There are four stages.
Without a VPN: four stages
Stage 1, DNS. Your laptop asks "where is shop.example.hk?" and gets an address back. In most setups this goes out in plain text, so the café and the ISP learn the site name here.
Step 1 DNS: "where is shop.example.hk?"
Laptop ──► DNS server : shop.example.hk ? (plain text)
Laptop ◄── DNS server : 203.0.113.10 (plain text)
Stage 2, the TCP three-way handshake. Before any data, your laptop and the shop check they can hear each other, in three messages: SYN, SYN-ACK, ACK. Think of it as "Hello?", "Yes, hello", "Good, let's talk". Everything in these three packets is plain: both addresses, the port (443 for HTTPS) and the timing. There is no content yet, so there is nothing to read, but the handshake tells any observer that a conversation with the shop has started. More on the handshake.
Step 2 TCP three-way handshake: "are you there?"
Laptop ──► Shop : SYN "I'd like to talk, here is my starting number"
Laptop ◄── Shop : SYN-ACK "Got it. Here is mine"
Laptop ──► Shop : ACK "Got yours. We're connected"
Visible on the way: both addresses, port 443, the timing. No content yet.
Stage 3, the TLS handshake. Now your browser and the shop agree a secret key. Your browser says which site it wants (that name travels in plain text, a field called SNI), the shop proves who it is with its certificate, and each side contributes half of the key. After a few messages, both hold the same secret and nobody else does. This is the padlock. More on TLS.
Step 3 TLS handshake: agreeing a secret key (this is the padlock)
Laptop ──► Shop : ClientHello "I speak TLS 1.3; I want shop.example.hk" ← site name in plain text (SNI)
Laptop ◄── Shop : ServerHello + certificate + its half of the key
Laptop ──► Shop : its half of the key + "Finished"
Both sides now hold the same secret key. Nobody on the path has it.
Stage 4, the request itself. Only now does your browser send "GET /cart", your login cookie, your card details. All of it is sealed with the key from stage 3. To the café and the ISP it's random bytes.
Step 4 The actual request, sealed with that key
Laptop ──► Shop : [TLS{ GET /cart cookie=… }] ← looks like random bytes to everyone else
Laptop ◄── Shop : [TLS{ 200 OK <html>… }]
So the honest baseline: HTTPS protects the contents from stage 4 on. What it doesn't hide is where you go, which leaked in stages 1 and 3, and the fact that you're talking to the shop, visible since stage 2.
With a VPN: one extra stage, then everything goes inside it
Switch on the VPN app and it adds a stage 0 before anything else: it builds a tunnel to one VPN server, say in Singapore. Your laptop and that server do their own handshake and agree their own secret key, the same idea as stage 3, but one level lower.
Step 0 Build the tunnel (WireGuard shown; OpenVPN does the same with TLS)
Laptop ──► VPN server : handshake initiation (my public key, a fresh random value)
Laptop ◄── VPN server : handshake response (its public key, its random value)
Both sides now hold a tunnel key. From here on, EVERY packet is wrapped.
From this moment the app takes over your laptop's routing. Stages 1 to 4 still happen exactly as before, but every packet of them, DNS lookup, SYN, ClientHello, the sealed request, is put inside a second envelope addressed to the VPN server and encrypted with the tunnel key. Here is one stage-4 packet as it leaves your laptop:
One packet of step 4, as it leaves your laptop with the VPN on:
┌─ outer envelope: from laptop ─ to VPN server (UDP 51820) ──────────────────┐
│ ┌─ WireGuard encryption ────────────────────────────────────────────────┐ │
│ │ ┌─ inner envelope: from laptop ─ to shop.example.hk (TCP 443) ──────┐ │ │
│ │ │ ┌─ TLS encryption (the padlock) ──────────────────────────────┐ │ │ │
│ │ │ │ GET /cart cookie=… │ │ │ │
│ │ │ └─────────────────────────────────────────────────────────────┘ │ │ │
│ │ └─────────────────────────────────────────────────────────────────┘ │ │
│ └───────────────────────────────────────────────────────────────────────┘ │
└───────────────────────────────────────────────────────────────────────────┘
Cafe + ISP see only the outer envelope. VPN server opens it, sees the inner envelope.
Only the shop opens the padlock.
The packet then crosses the café, the ISP and the internet to the VPN server. The server strips the outer envelope, finds the inner one addressed to the shop, and sends it on with its own address as the sender. The reply comes back to the VPN server, gets wrapped, and travels through the tunnel to you.
Laptop ══ cafe Wi-Fi ══ cafe router ══ ISP ══ internet ══ VPN server ──── internet ──── shop.example.hk
◄──────── everything inside the tunnel (outer envelope only) ────────► ◄── inner envelope + padlock ──►
Notice what the VPN did and didn't change. The three-way handshake and the TLS handshake still take place between your laptop and the shop; the VPN just carries them. Your laptop also does a separate handshake with the VPN server at stage 0. And the padlock from stage 3 is never opened by the VPN server: it forwards the inner envelope still sealed.
Who sees what
| Who | Without a VPN | With a VPN |
|---|---|---|
| People on the café Wi-Fi | site name (DNS, SNI), shop address, timing, volume | one stream to the VPN server; nothing else |
| The café router and its ISP | the same | the same: VPN server address, timing, volume |
| The VPN company | not involved | site name and address, timing, volume (what the café used to see) |
| The shop | your café's public address, plus everything you type | the VPN server's address, plus everything you type |
| Anyone, anywhere | your card number, the page contents | still nobody: the padlock is untouched |
Two lines in that table matter most. The café and the ISP lose almost everything they could see, which is the point of using a VPN on public Wi-Fi. And the VPN company gains exactly what they lost. A VPN doesn't remove the party who can watch where you go; it chooses a different one. Picking that company well is the subject of the next article.
The two layers, side by side
| TLS (the padlock, stage 3) | The VPN tunnel (stage 0) | |
|---|---|---|
| Who agrees the key | your browser and one website | your device and the VPN server |
| What it seals | the contents of that one site | every packet leaving your device, handshakes included |
| Who can open it | you and the website | you and the VPN server |
| Where it ends | at the website | at the VPN server |
If a site doesn't use HTTPS, there is no inner padlock: the VPN protects you only as far as the VPN server, and from there to the site your data travels open. The tunnel is built by a VPN protocol; the two you'll meet most are WireGuard, newer and fast, and OpenVPN, older and everywhere. Both do the same job: a handshake, then wrapping and checking every packet.
What a VPN does not do
-
It doesn't make a bad site safe. A phishing page looks the same through a tunnel.
-
It doesn't hide you from sites you log in to. Google, Facebook or your bank know it's you because you told them.
-
It doesn't stop malware already on your device from sending data out, through the tunnel like everything else.
-
It doesn't always hide your DNS. A poorly made app can let stage 1 leak outside the tunnel; good apps send it through, and encrypted DNS (DNS over HTTPS) closes the gap even without a VPN. A newer HTTPS feature, Encrypted Client Hello, is starting to hide the site name in stage 3 too.
-
It isn't needed to encrypt your banking. Stage 3 already does that. What the VPN adds on public Wi-Fi is hiding where you go and stopping anyone on the same network from redirecting you.
A note for Hong Kong readers: using a VPN is legal here. This series is about privacy on shared networks and reaching your own office or home systems safely, which is where we see businesses use them.
Coming next
Article two looks at the party we introduced today, the VPN company: what it logs, why free VPNs are rarely free, and the questions to ask before paying. Article three is for people who want more control: taking the WireGuard or OpenVPN configuration from your VPN account and using it on a router, a NAS or your own software.
The padlock seals what you read. The tunnel hides where you go, from everyone except the VPN company.
If your team works from cafés and client offices and you'd like a setup that connects them safely to your own systems, let's talk.
