VPNs Explained: How Virtual Private Networks Work
A Virtual Private Network (VPN) creates a protected tunnel across an untrusted network so that traffic between two endpoints stays private and authenticated. VPNs matter because they let remote workers reach internal systems safely, connect branch offices over the public internet, and shield traffic from eavesdroppers on shared networks. Understanding how a VPN encapsulates and encrypts packets clarifies both its strengths and its limits.
What a VPN Is and Why It Matters
A VPN extends a private network across public infrastructure by wrapping traffic so that intermediaries see only the encrypted tunnel, not the contents. The two ends of the tunnel authenticate each other and agree on encryption keys, after which packets are protected as they traverse networks neither party controls.
Organizations use VPNs to:
- Give remote users access to internal resources as if they were on-site.
- Link geographically separate sites into one logical network.
- Protect traffic on shared or hostile networks such as public Wi-Fi.
Tunneling and Encapsulation
The defining mechanism of a VPN is tunneling: taking a complete packet and placing it inside the payload of another packet. This is called encapsulation. The original packet, with its own source and destination addresses, becomes the cargo; a new outer header addresses the packet to the far tunnel endpoint.
When the encapsulated packet arrives, the receiving endpoint strips the outer header, decrypts the payload, and forwards the inner packet toward its real destination. Because the inner packet is hidden inside the outer one, private addressing and the true contents are concealed from anyone watching the path.
Encapsulation can operate at different layers. Some VPNs tunnel at the network layer, carrying IP packets; others tunnel at higher layers. The choice affects what kinds of traffic the tunnel can carry and how it interacts with routing.
How VPN Encryption Protects Traffic
Encapsulation alone hides structure but not content. A VPN adds cryptographic protection so the tunnel delivers:
- Confidentiality through symmetric encryption of the encapsulated payload.
- Integrity through authentication codes that detect any modification.
- Authentication so each endpoint proves its identity, typically with certificates or pre-shared keys.
These are the same guarantees provided by TLS, and indeed some VPNs are built directly on TLS. As with any secure channel, ephemeral key exchange gives forward secrecy, so recording the tunnel and later compromising a key does not expose past sessions.
Common VPN Protocols
Several protocol families dominate, each with a different design philosophy.
IPsec
IPsec secures traffic at the network layer. It uses the Encapsulating Security Payload (ESP) to encrypt and authenticate packets and the Internet Key Exchange (IKE) protocol to negotiate keys and establish security associations. IPsec can run in tunnel mode, which encapsulates the entire original packet, or transport mode, which protects only the payload. It is a traditional backbone of site-to-site connectivity.
WireGuard
WireGuard is a streamlined protocol that uses a fixed, opinionated set of quality cryptographic primitives and a small codebase. It authenticates peers using public keys and establishes tunnels quickly with minimal negotiation, which makes it fast and comparatively simple to audit. A minimal client configuration shows how compact the model is:
[Interface]
PrivateKey = <client private key>
Address = 10.0.0.2/32
[Peer]
PublicKey = <server public key>
AllowedIPs = 10.0.0.0/24
Endpoint = vpn.example.com:51820
TLS-Based VPNs
TLS-based VPNs, such as those using OpenVPN, tunnel traffic inside a TLS session, frequently over port 443. Riding on the same port as HTTPS helps this style traverse restrictive networks that would block other protocols.
Remote Access Versus Site-to-Site
VPNs are commonly deployed in two topologies:
- Remote access connects an individual device to a network. Client software builds a tunnel to a gateway, and the user's traffic enters the private network through it.
- Site-to-site connects whole networks. Gateways at each location maintain a persistent tunnel, so hosts on either side communicate without running any VPN software themselves.
A related design choice is split tunneling, where only traffic destined for the private network goes through the tunnel while other traffic uses the local connection directly. This improves performance but widens exposure, so it is a policy decision rather than a default.
What a VPN Does and Does Not Hide
A VPN is often described as making you anonymous, which overstates its function. Accurately, a VPN:
- Hides your traffic contents and destinations from local observers and your internet provider.
- Replaces your source IP address, as seen by destinations, with the VPN gateway's address.
It does not, however, make you anonymous to the VPN operator, who can see the traffic entering and leaving the tunnel. It also does not protect data after it exits the tunnel, nor does it substitute for endpoint security or a zero trust approach to access. Trust simply shifts from the local network to the VPN provider.
Key Takeaways
- A VPN builds an encrypted, authenticated tunnel across untrusted networks using encapsulation.
- Tunneling wraps a whole packet inside another, hiding private addressing and contents from the path.
- Encryption adds confidentiality, integrity, and endpoint authentication, mirroring TLS guarantees.
- IPsec, WireGuard, and TLS-based VPNs represent different trade-offs in flexibility, speed, and simplicity.
- A VPN relocates trust to the VPN operator and does not by itself provide anonymity or endpoint security.