Please enable JavaScript to use CodeHS

Cybersecurity Basics

What is a VPN?

A VPN wraps your internet traffic in an encrypted tunnel so no one along the way can peek inside. Learn how it works, and try an interactive diagram that shows what changes with a VPN turned on.

Security ~9 min Beginner friendly
The Big Idea

The postcard problem

Think about the difference between mailing a postcard and mailing a sealed letter. A postcard has no envelope. Anyone who touches it along the way — the mail truck driver, someone sorting mail at the post office — can flip it over and read every word, including who it's addressed to.

A lot of ordinary internet traffic works more like a postcard than a sealed letter. When you connect to the internet, your traffic passes through your internet service provider (the company that connects your home to the internet), and if you're on public Wi-Fi, it can also pass through the same network as everyone else in that coffee shop, airport, or library.

That means someone in the right position — your internet provider, or a stranger on the same public Wi-Fi — can potentially see which websites you're visiting, even if they can't see everything you typed. On a network you don't fully trust, that's a real privacy problem.

Simple definition: unprotected internet traffic can be like a postcard — readable by anyone handling it along the way, not just the person it's addressed to.

This is exactly the kind of problem a VPN is designed to solve.


How It Works

How a VPN works

A VPN, or Virtual Private Network, takes your postcard and puts it inside a locked box before it leaves your device. That locked box is called encryption — it scrambles your data into gibberish that only one specific key can unscramble.

Here's the flow: your device connects first to a server run by the VPN company. Everything between your device and that server travels through an encrypted tunnel, so it looks like scrambled nonsense to anyone watching along the way — even your internet provider. Only the VPN server holds the key to unlock it.

Once your traffic arrives at the VPN server, it gets unlocked and sent out to the real internet from there. This has an interesting side effect: the website you're visiting sees the VPN server's location and address, not your real one. If the VPN server is in another city, the website thinks you're browsing from that city.

Your Device → Encrypted Tunnel → VPN Server → Real Internet
1. Your device
2. Encrypted tunnel
3. VPN server
4. The website

Think of it like this: encryption is a locked box. Your device has the only key that fits the VPN server's lock, so anyone who intercepts the box along the way just sees a sealed, unopenable container — not what's inside.


Interactive

No VPN vs. with VPN

Imagine you're on public Wi-Fi at a coffee shop, and someone else on that same network is nosy enough to try to peek at other people's traffic. Toggle the switch below to see what that watcher can and can't see.

VPN comparison
You
Watcher
visiting: homework-help.com searching: how to beat level 5 logging in: mymail.com
VPN server
Internet

No VPN: the watcher on the same Wi-Fi network can read exactly which sites you're visiting and what you're searching for.


Myth vs. Reality

What VPNs don't do

VPNs are great at one specific job: hiding your traffic from anyone on the network path between you and the VPN server. But a lot of people expect them to do more than that. Here's where the myths break down.

Myth: full anonymity

"A VPN makes me completely anonymous online."

Reality: once you log into a site — your email, a game, social media — that site still knows it's you, VPN or not. A VPN hides your network location, not your identity after you sign in.

Myth: fixes weak passwords

"A VPN protects my accounts even if my password is weak."

Reality: a VPN protects data in transit, not your account itself. A reused or guessable password can still be cracked or leaked with a VPN on. That's a job for a strong, unique password.

Myth: invisibility cloak

"With a VPN, nothing I do online can ever be tracked."

Reality: a VPN is one good habit, not a magic cloak. Good passwords, two-factor authentication, and watching out for phishing and malware still matter — a VPN doesn't replace any of them.

Remember: a VPN protects the trip your data takes across the network. It doesn't protect the account you log into at the other end — that's still on you.


Your Turn

Check your understanding

Why might someone using public Wi-Fi at a coffee shop want to use a VPN?

Your answer:

Sample answer: public Wi-Fi is shared with strangers, and some of them might be able to see traffic on that network. A VPN wraps their traffic in an encrypted tunnel before it leaves their device, so even if someone else on the coffee shop's Wi-Fi tries to look, all they see is scrambled data instead of which sites the person is visiting.


Check Yourself

Quick quiz

1. What does a VPN actually do to your internet traffic?

2. What problem is a VPN mainly designed to solve?

3. Which statement about VPNs is true?

Keep learning about digital safety

You've now covered how attackers target networks — from firewalls to VPNs — and how they target people, with social engineering and malware. Next, see how attackers target something newer: AI systems themselves.

Part of the Cybersecurity Basics tutorial series.