A VPN doesn’t just hide your IP address; it fundamentally re-routes and encrypts all your internet traffic, making it look like it’s originating from the VPN server’s location.

Let’s see this in action. Imagine you want to access a website, say example.com. Normally, your computer would send a request directly to example.com.

Your Computer --> Internet --> example.com

With a VPN, it’s a bit more involved. Your request first goes to the VPN server, which then forwards it to example.com. The response from example.com comes back to the VPN server, which then sends it back to your computer.

Your Computer --> [Encrypted Tunnel] --> VPN Server --> Internet --> example.com
                                            ^                                    |
                                            |                                    |
                                            -------------------------------------

The key here is the "[Encrypted Tunnel]". This is where the magic happens.

The Tunnel: Encapsulation and Forwarding

Think of your internet traffic as a letter you want to send. Without a VPN, you put the letter in an envelope with the recipient’s address and drop it in a public mailbox. Anyone handling it can see where it came from and where it’s going.

With a VPN, you first put that letter inside another envelope. This outer envelope has the address of the VPN server. This is called encapsulation. Your original data packet (the letter) is wrapped inside a new packet (the outer envelope). This outer packet is then sent to the VPN server.

When the VPN server receives this outer packet, it opens it, takes out your original letter, and then puts it into a new outer envelope addressed to the actual destination (example.com). It then sends this new packet out into the internet. This is the forwarding part. The VPN server acts as an intermediary, making it appear as though the request originated from its own IP address, not yours.

Encryption: The Secret Ink

The crucial part of this "outer envelope" is that it’s sealed with encryption. When your VPN client (the software on your computer) establishes a connection with the VPN server, they negotiate a secret key. This key is used to scramble (encrypt) your data before it’s put into the outer envelope.

For example, if your original data is GET / HTTP/1.1, after encryption with a AES-256 cipher, it might look like a jumbled mess of characters, say aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789. This encrypted data is what gets encapsulated in the outer packet and sent to the VPN server.

The VPN server, using the same secret key, can then decrypt this scrambled data back into its original form (GET / HTTP/1.1). It then sends this unencrypted request to the final destination, example.com. The response from example.com is then encrypted by the VPN server before being sent back to your computer, where your VPN client decrypts it.

This encryption prevents anyone sniffing traffic between your computer and the VPN server (like your ISP, or someone on the same Wi-Fi network) from understanding what you’re doing online. They can see that you’re connected to a VPN server and the volume of data, but not the content.

Protocols: The Rules of Engagement

The "how" of this tunneling and encryption is governed by various VPN protocols. These are essentially sets of rules and standards that define how the VPN connection is established, how data is encrypted, and how it’s tunneled. Common ones include:

  • OpenVPN: Highly configurable, open-source, and considered very secure. It can run over UDP (faster, less reliable) or TCP (slower, more reliable) ports.
  • WireGuard: A newer, simpler, and faster protocol designed for modern cryptography. It aims for better performance and easier auditing.
  • IKEv2/IPsec: Often used for mobile devices due to its stability and ability to quickly re-establish connections when switching networks.
  • L2TP/IPsec: An older protocol, generally considered less secure and slower than OpenVPN or WireGuard, but still widely supported.

The protocol you choose affects the speed, security, and reliability of your VPN connection. For instance, WireGuard often boasts significantly higher speeds due to its streamlined design and modern encryption algorithms.

The primary problem a VPN solves is privacy and security over untrusted networks. By encrypting your traffic and routing it through a trusted server, it shields your online activities from eavesdroppers and masks your true location.

One of the most surprising aspects is how much control you have over the exit node. When you connect to a VPN server, you’re not just getting a new IP address; you’re choosing which physical server’s IP address your traffic will appear to come from. This allows you to bypass geo-restrictions by appearing to be in a different country, or even to access your home country’s services while abroad.

The next concept to explore is how VPNs handle DNS requests and what happens if they leak.

Want structured learning?

Take the full Computer Networking course →