How a VPN Actually Works
A VPN puts each of your packets inside an encrypted envelope and gives it a new return address. Here's the tunnel, the encryption, and what a VPN does and doesn't protect.
VPNs are often advertised as a way to become anonymous online.
That's not what a VPN does. A VPN (Virtual Private Network) does two well-understood things. It encrypts every packet, so the networks between you and the VPN server can't read them. And it replaces your return address, so the websites you visit see the server's IP (Internet Protocol) address instead of yours.
Once those two things are clear, you can tell what a VPN protects and what it can't.
The problem: your packets are postcards
Normally, when you load a website, your packets travel like postcards. Anyone who handles a postcard can read the address on it. In the same way, every network on the path can read the outside of your packets: your Wi-Fi, the café's router, your ISP (Internet Service Provider), and every network after that.
HTTPS (Hypertext Transfer Protocol Secure) already encrypts the content of a page. But the information around it, the metadata, is still visible. Your ISP still sees the name of every website you connect to, through DNS (Domain Name System) lookups and through the site name sent at the start of the TLS (Transport Layer Security) handshake. And every website you visit sees your IP address, which shows your rough location and which ISP account you use.
The trick: a tunnel
A VPN puts each of your packets inside another packet. This is called encapsulation. The inner packet is encrypted, and the outer packet is addressed to a VPN server.
The VPN server decrypts the inner packet, replaces your address with its own, and sends the packet on to the real destination. Replies come back to the server, which encrypts them and sends them back to you through the same tunnel.
That diagram shows what each party can see.
Your ISP and the café Wi-Fi now see only an encrypted stream going to one VPN server. They see no website names and no destinations.
The website sees the VPN server's IP address, not yours. As far as it knows, you are in whichever city that server is in.
The VPN provider sees everything your ISP used to see. You haven't removed the party you have to trust. You have chosen a different one.
That last point is the most important thing to understand about VPN services. A VPN moves your trust from your ISP to your VPN provider. Whether that's an improvement depends entirely on the provider.
What is inside the tunnel
Modern VPN protocols do three jobs.
| Job | What it means | Typical tool |
|---|---|---|
| Key exchange | You and the server agree on a secret key without ever sending it | Diffie-Hellman |
| Encryption | Each packet is scrambled with that key | ChaCha20 or AES-256 |
| Authentication | Each packet carries a tamper-proof seal | Poly1305 or GCM tags |
Key exchange is the clever part. Each side has a private key, which it never shares, and a public key made from it, which it can send openly. Each side combines its own private key with the other side's public key, and both end up with the same secret. Someone watching sees only the public keys, and can't work out the secret from them.
WireGuard, the protocol most modern VPNs use, is known for being small. It's about 4,000 lines of code inside the Linux kernel, compared with hundreds of thousands of lines for OpenVPN. Less code means fewer places for security bugs, and code that experts can actually check.
Its design is plain. Each side has a key pair, much like with SSH (Secure Shell), and each side knows the other's public key in advance. Only a peer that holds the matching private key can complete the handshake, and setting up the connection takes one round trip.
WireGuard handshake (simplified):
you ── handshake initiation (your ephemeral pubkey) ──► server
you ◄── handshake response (server ephemeral pubkey) ── server
both sides now derive the same session key
you ══ encrypted packets, rekeyed every 2 minutes ══► server
WireGuard makes new session keys every two minutes. This gives you forward secrecy: even if someone records your traffic today and steals a long-term key next year, the old sessions stay unreadable. Each session key was thrown away after use, and the stolen key can't rebuild them.
What a VPN doesn't do
Advertisements usually leave this part out.
It doesn't make you anonymous. If you are logged into your Google account through the tunnel, Google still knows exactly who you are. Cookies, logins and browser fingerprinting, which identifies a browser by its settings, all identify you whatever your IP address is.
It doesn't make a bad website safe. If a site is harmful or unencrypted, the VPN delivers the same harmful content, just through an encrypted tunnel.
It doesn't hide that you are using a VPN. Your stream to the VPN server is visible, and the IP addresses of VPN servers are well known. That's exactly how streaming services block VPNs.
DNS can leak. If your computer sends its DNS lookups outside the tunnel, your ISP still sees every website name you look up. Good VPN apps force DNS through the tunnel, and it's worth checking that yours does.
The kill switch matters. If the tunnel drops and your traffic quietly goes back to the normal connection, you are exposed without knowing it. A kill switch blocks all traffic while the tunnel is down.
The Bottom Line
I keep a VPN indicator on my desktop's status bar. It's a small Go program that checks the connection every few seconds and shows the country and city of the server. I built it because of that fallback problem.
The dangerous case isn't the VPN being off. It's the VPN being off without you noticing. Showing the tunnel's state on screen all the time makes that failure visible.
A VPN encrypts your packets, replaces your address with the server's address, and moves your trust from your ISP to the VPN provider. Those three facts are enough to judge most claims about VPNs.
Check yourself
3 questions · nothing is savedReferences & Primary Sources
Official specifications, standards, and documentation cited in this post.
- [1]
Jason A. Donenfeld's formal paper detailing Noise framework cryptography and cryptokey routing
PAPERwireguard.com - [2]
Kernel documentation on virtual layer-2/layer-3 packet capture and transmission in userspace
DOCSdocs.kernel.org - [3]
Foundational IETF standards for cryptographic protection of IP communications
RFCrfc-editor.org
- Written
- Dec 8, 2025
- Length
- 1,021 words · 5 min
- Built
- …
- Served by
- …
- Delivered
- …
- Over the wire
- …
- Go's share
- …
Eduroam on Linux: Why One Wi-Fi Network Is So Hard to Join
Eduroam isn't a Wi-Fi password, it's a personal login that works across thousands of universities. Here's how it works, why Linux has trouble with it, and the settings that work.
