A VPN wraps your network traffic inside an encrypted tunnel to another network. This article explains where VPNs came from, how the tunnel really works, and when you need one and when you don't.
Few technologies are as widely used and as widely misunderstood as the VPN. Companies use VPNs to connect offices and give employees access to internal systems. Millions of people pay for consumer VPN apps that promise privacy and anonymity. Yet many people cannot say what a VPN actually does to a packet, or what it protects against.
This article goes from the history of VPNs, from leased lines to WireGuard, to the mechanics of tunnelling, routing and encryption, compares the main protocols, and ends with an honest answer to the question "should I use one?". It continues the networking series after How HTTPS Really Works and DNS in Depth.
1. What a VPN Is
A virtual private network makes a remote computer behave as if it were plugged into another network. Your laptop in a hotel gets an address in the company network, can reach internal servers, and its traffic looks, to those servers, as if it came from inside.
It does this with three ingredients:
- Encapsulation: each packet is put inside another packet, addressed to the VPN server. This is the tunnel.
- Encryption: the inner packet is encrypted, so nobody on the path can read it.
- Authentication: both ends prove who they are, so nobody can join the network or impersonate the server.
The name explains the idea. The network is private because only authorised devices can join and nobody outside can read the traffic. It is virtual because it does not have its own cables; it runs over the public internet.
Here is the same request without and with a VPN:
Without VPN:
laptop ──> hotel Wi-Fi ──> ISP ──> internet ──> server
everyone on the path sees: laptop → server, port 443
With VPN:
laptop ══> hotel Wi-Fi ══> ISP ══> VPN server ──> server
the path sees only: laptop → VPN server, encrypted
the server sees: VPN server → server
The double lines are the tunnel. Everything inside is encrypted. After the VPN server, the traffic continues normally, as if it had started there.
2. A Short History
VPNs exist because companies wanted private networks without paying for private cables.
| Period | Technology | What changed |
|---|---|---|
| 1980s–1990s | Leased lines, Frame Relay, ATM | Real private circuits from telecom providers: secure by isolation, very expensive |
| 1995–1998 | IPsec (RFC 1825–1829, later RFC 2401) | Encryption and authentication built into IP itself |
| 1996–1999 | PPTP (Microsoft and partners) | Easy dial-up style VPN, built into Windows |
| 1999–2001 | L2TP, then L2TP over IPsec | Tunnelling from PPTP, encryption from IPsec |
| Early 2000s | SSL VPNs, OpenVPN (2001) | VPNs over TLS, easier through firewalls and NAT |
| 2005–2014 | IKEv2 (RFC 4306, RFC 7296) | Faster, more robust key exchange for IPsec, good for mobile |
| 2013 onwards | Consumer VPN boom | After the Snowden revelations, privacy became a mass market |
| 2014 | Google BeyondCorp | Zero trust: no trusted network, check every request |
| 2016–2020 | WireGuard | A small, modern VPN, in the Linux kernel since version 5.6 (2020) |
| 2019 onwards | Mesh VPNs (Tailscale and others) | WireGuard tunnels between every pair of devices, managed centrally |
Leased lines: private by isolation
Before VPNs, a company with two offices rented a dedicated line from a telecom provider. The line was private because nobody else used it. It was also slow, expensive and charged by distance. When the internet became cheap and everywhere in the 1990s, the obvious question was: can we send company traffic over the public internet and still keep it private?
PPTP and IPsec: two answers in the 1990s
IPsec, developed at the IETF from 1992 and first standardised in 1995, answered that question at the network layer: it adds encryption and authentication to IP packets themselves. It is powerful and became the standard for connecting networks, but its configuration is famously complex.
PPTP (Point-to-Point Tunneling Protocol), developed by a consortium led by Microsoft around 1996, was the easy answer. It came with Windows, worked like the dial-up connections people already knew, and spread quickly. It was also badly broken. Bruce Schneier and Mudge published weaknesses in 1998 and 1999, and in 2012 Moxie Marlinspike showed that a captured PPTP login (MS-CHAPv2) could be cracked by breaking a single 56-bit DES key, a matter of hours with dedicated hardware. PPTP should not be used for anything today.
OpenVPN: VPNs over TLS
In 2001 James Yonan released OpenVPN. Instead of a new protocol at the IP layer, it used the same TLS that protects websites, running over ordinary UDP or TCP ports. That made it work through NAT routers and most firewalls, which IPsec struggled with at the time. Commercial "SSL VPN" products followed the same idea, often running in the browser or a small client.
WireGuard: starting over
By the 2010s, IPsec and OpenVPN were mature but large, with many options, many algorithms and a lot of code. In 2016 Jason Donenfeld published WireGuard: a VPN with one fixed set of modern algorithms, no negotiation, and a code base of about 4,000 lines, small enough for one person to audit. Linus Torvalds called it "a work of art" in 2018, and it was merged into the Linux kernel in 2020. Today it is the basis of most new VPN products.
3. How a Tunnel Works
A tunnel is simple at its core: take a packet, encrypt it, put it inside a new packet, send it to the other end, and reverse the steps there.
The virtual interface
On your laptop, the VPN software creates a virtual network interface, for example wg0 or tun0. To the operating system it looks like a network card. The difference is what happens to packets sent through it:
- An application sends a packet to
10.20.0.15, an internal server. - The routing table says:
10.20.0.0/16goes throughwg0. - The VPN software receives the packet from
wg0, encrypts it and wraps it in a UDP packet addressed to the VPN server, for example203.0.113.10:51820. - That outer packet leaves through the real network card, like any other UDP packet.
- The VPN server receives it, checks and decrypts it, and gets the original packet back.
- The server forwards the original packet to
10.20.0.15inside the company network.
The answer travels the same way back.
A packet inside a packet
Here is what a WireGuard packet looks like on the wire, sent over IPv4:
┌──────────┬─────────┬──────────────────┬─────────────────────┬─────────┐
│ IPv4 │ UDP │ WireGuard header │ encrypted inner │ auth │
│ 20 bytes │ 8 bytes │ 16 bytes │ IP packet │ tag 16 │
└──────────┴─────────┴──────────────────┴─────────────────────┴─────────┘
outer, readable by everyone inner, encrypted with ChaCha20
laptop → VPN server, port 51820 laptop 10.8.0.2 → 10.20.0.15:443
Anyone on the path sees only the outer header: your real address, the VPN server's address, UDP port 51820, and the packet size. The inner packet, with the real destination, port and content, is encrypted and authenticated with ChaCha20-Poly1305, the same AEAD cipher used in TLS 1.3.
The cost: overhead and MTU
Every packet carries this extra wrapping. For WireGuard it is 60 bytes over IPv4 and 80 bytes over IPv6. Normal Ethernet packets are limited to 1,500 bytes (the MTU, maximum transmission unit), so the inner packet must be smaller:
1500 physical MTU
-40 outer IPv6 header (worst case)
-8 UDP header
-32 WireGuard header + authentication tag
────
1420 MTU of the wg0 interface (WireGuard's default)
If the MTU is wrong, large packets are dropped or fragmented, and you get one of the most confusing VPN symptoms: small requests work, SSH works, but large downloads or some websites hang. The fix is almost always the MTU.
4. Routing: Full Tunnel or Split Tunnel
The VPN decides nothing by itself. The routing table decides which traffic goes into the tunnel.
| Mode | Routes through the tunnel | Typical use |
|---|---|---|
| Full tunnel | Everything (0.0.0.0/0 and ::/0) | Consumer VPNs, strict company policies |
| Split tunnel | Only internal networks (for example 10.0.0.0/8) | Company access while video calls go directly |
A full tunnel protects everything but sends all traffic, including Netflix and video calls, through the VPN server, which costs bandwidth and latency. A split tunnel is faster and lighter but leaves the rest of the traffic outside the tunnel.
Three details decide whether a VPN really does what you expect:
- DNS. If the tunnel carries your traffic but DNS queries still go to the hotel's resolver, everyone on that network still sees every name you look up. This is a DNS leak. A good VPN client sets its own DNS server inside the tunnel. (DNS in Depth explains why that matters.)
- IPv6. If the VPN only tunnels IPv4 and your network also has IPv6, some traffic may bypass the tunnel completely.
- Kill switch. When the tunnel drops, a careless client falls back to the normal connection without telling you. A kill switch blocks all traffic until the tunnel is back.
5. The Main Protocols
Three protocol families cover almost all VPNs in use today:
| IPsec / IKEv2 | OpenVPN | WireGuard | |
|---|---|---|---|
| Since | 1995 (IKEv2: 2005) | 2001 | 2016 (kernel: 2020) |
| Layer | Network layer (IP) | User space over TLS | Kernel, over UDP |
| Transport | ESP, UDP 500 and 4500 | UDP or TCP, default 1194 | UDP, often 51820 |
| Crypto | Negotiated, many options | Negotiated via TLS | Fixed modern set |
| Code size | Large | Large (plus TLS library) | About 4,000 lines |
| Strength | Standard everywhere, routers, phones | Works almost anywhere, also over TCP 443 | Fast, simple, roams well |
| Weakness | Complex configuration | Slower, more overhead | UDP only, fewer enterprise features |
IPsec and IKEv2
IPsec has two parts. IKE (Internet Key Exchange, today IKEv2) does the handshake: both sides authenticate with certificates or a shared key and agree on keys. ESP (Encapsulating Security Payload) then encrypts the packets. IPsec is built into every operating system, every enterprise firewall and every phone, which makes it the standard for site-to-site VPNs between offices and clouds. Behind NAT routers, ESP is wrapped in UDP port 4500 (NAT traversal).
OpenVPN
OpenVPN runs in user space and uses a TLS library for its handshake. Its big advantage is flexibility: it can run over TCP port 443 and look like ordinary HTTPS traffic, which gets it through restrictive networks. The price is performance: every packet crosses between kernel and user space, and TCP inside TCP behaves badly on lossy links, because both layers retransmit lost data.
WireGuard
WireGuard takes the opposite approach to configurability: there are no options to choose. It uses the Noise protocol framework with Curve25519 for key exchange, ChaCha20-Poly1305 for encryption, BLAKE2s for hashing and HKDF for key derivation. If one of them is ever broken, the answer is a new protocol version, not a negotiation. That removes whole classes of bugs, such as downgrade attacks, and makes WireGuard fast and easy to audit.
6. WireGuard in Practice
WireGuard's configuration shows how simple a modern VPN can be. Each device has a key pair, created like this:
wg genkey | tee private.key | wg pubkey > public.key
The server, /etc/wireguard/wg0.conf:
[Interface]
Address = 10.8.0.1/24
ListenPort = 51820
PrivateKey = <server-private-key>
[Peer]
# Maziar's laptop
PublicKey = <laptop-public-key>
AllowedIPs = 10.8.0.2/32
The laptop:
[Interface]
Address = 10.8.0.2/32
PrivateKey = <laptop-private-key>
DNS = 10.8.0.1
[Peer]
PublicKey = <server-public-key>
Endpoint = vpn.example.com:51820
AllowedIPs = 0.0.0.0/0, ::/0
PersistentKeepalive = 25
Start it with wg-quick up wg0. The important ideas:
- Keys are identities. There are no user names or passwords. A peer is its public key, like in SSH.
- AllowedIPs does two jobs. On the laptop,
0.0.0.0/0, ::/0means "send everything through the tunnel" (a full tunnel). On the server,10.8.0.2/32means "packets from this peer may only carry this source address". WireGuard calls this cryptokey routing: the key decides which addresses a peer may use. - DNS inside the tunnel prevents the DNS leak from section 4.
- PersistentKeepalive sends a small packet every 25 seconds so NAT routers keep the connection open.
wg show displays the state (example output, shortened):
interface: wg0
public key: <laptop-public-key>
listening port: 41922
peer: <server-public-key>
endpoint: 203.0.113.10:51820
allowed ips: 0.0.0.0/0, ::/0
latest handshake: 41 seconds ago
transfer: 3.21 MiB received, 812.44 KiB sent
WireGuard does a fresh handshake at least every two minutes, so the session keys change constantly (forward secrecy, as in TLS 1.3). It also stays silent: a WireGuard server does not answer packets without a valid key, so a port scan cannot even tell that it is there. And because a peer is identified by its key, not its address, the tunnel survives moving from Wi-Fi to mobile data without reconnecting.
7. Three Kinds of VPN
The word "VPN" is used for three different things:
| Kind | Connects | Who uses it | Typical protocol |
|---|---|---|---|
| Site-to-site | Two networks, for example office and cloud | Companies | IPsec |
| Remote access | One device to a company network | Employees, administrators | IPsec/IKEv2, OpenVPN, WireGuard, SSL VPN |
| Consumer VPN | One device to a VPN provider, then the internet | Private users | WireGuard, OpenVPN, IKEv2 |
The first two extend a private network to a place that is not physically connected to it. The third does something quite different: it moves the exit point of your internet traffic to a provider's server. That difference matters for the question of what a VPN protects.
8. What a VPN Protects, and What It Doesn't
A VPN encrypts traffic between your device and the VPN server. Everything follows from that one fact:
| Threat | Does a VPN help? |
|---|---|
| Access to internal company systems from outside | Yes, that is what it is for |
| Someone on public Wi-Fi reading or changing traffic | Yes, but HTTPS already protects most of it |
| Your ISP seeing which sites you visit (DNS, SNI, IPs) | Yes, the ISP sees only the VPN server |
| Websites seeing your real IP address and rough location | Yes, they see the VPN server |
| Tracking with cookies, logins and browser fingerprints | No, they work the same through a VPN |
| Malware, phishing, insecure websites | No, the VPN carries them faithfully |
| The VPN provider seeing your traffic | No, it now sees what your ISP saw before |
| Anonymity against a determined adversary | No, use Tor for that |
Two points deserve attention.
HTTPS changed the picture. In 2010, public Wi-Fi was dangerous because much of the web was unencrypted, and tools like Firesheep could steal sessions on café networks. Today almost all traffic is HTTPS, so an attacker on the Wi-Fi sees encrypted connections and the names of the sites you visit, not your passwords. A VPN still hides those names and protects apps that do not use TLS properly, but it is no longer the only defence.
A VPN moves trust, it does not remove it. Without a VPN, your ISP can see where you connect. With a consumer VPN, the VPN provider can see the same, and often more, because all your traffic goes through one company. "No logs" is a promise, not a technical property. Choose a provider with an independent audit, a clear jurisdiction and a business model that does not depend on your data. Free VPN apps are often paid for with exactly that data.
9. The Cost: Latency and Speed
A VPN adds a detour. Every packet goes from you to the VPN server and from there to the destination. How much that costs depends on where the server is:
| Setup | Extra round trip time |
|---|---|
| VPN server in the same city as you and the destination | 1–5 ms |
| You in Frankfurt, VPN server in Amsterdam, website in Frankfurt | about 15 ms |
| You in Frankfurt, VPN server in New York, website in Frankfurt | about 170 ms |
Every handshake of every new connection pays that extra time, several times over, as Latency Is the New Bandwidth showed. Choose a VPN server near you or near the services you use, not on the other side of the world.
The other costs are smaller:
- Overhead: 60 to 80 bytes per packet. For full-size packets that is about 4 to 5% of bandwidth; for small packets, such as voice calls, the share is much higher.
- Encryption: modern CPUs encrypt several gigabits per second, so on normal connections the cipher is not the bottleneck. On small routers and old phones it can be.
- Protocol: WireGuard in the kernel is usually fastest. OpenVPN over TCP is slowest, especially on lossy mobile networks.
10. Security Pitfalls
A VPN is a door into your network. That makes the VPN itself one of the most attacked parts of any company.
- The VPN gateway is the target. Since 2019, critical vulnerabilities in VPN appliances from Pulse Secure (CVE-2019-11510), Fortinet (CVE-2018-13379), Citrix (CVE-2019-19781) and Ivanti (CVE-2023-46805 and CVE-2024-21887) were exploited on a large scale, often within days of publication. Patch VPN gateways first, and fast.
- A VPN connection is often too trusted. Once connected, a user, or an attacker with stolen credentials, can often reach the whole internal network. Limit what VPN users can reach, and require multi-factor authentication.
- Weak protocols. PPTP is broken. Old IPsec setups with pre-shared keys and outdated ciphers are weak. Use IKEv2 with certificates, OpenVPN with current TLS, or WireGuard.
- Leaks. DNS leaks, IPv6 leaks and WebRTC in the browser can reveal your real address despite the tunnel. Test your setup, for example with a DNS leak test site, after every change.
- Shared keys. A WireGuard private key copied to five devices means five devices you cannot tell apart and cannot revoke one by one. One key pair per device.
11. Beyond the VPN: Zero Trust and Mesh Networks
The classic company VPN follows a castle model: a hard wall, and everything inside is trusted. Attackers have learned that they only need to get through the wall once.
In 2014 Google described BeyondCorp, its answer after a series of attacks: there is no trusted internal network. Every request to every application is checked on its own: who is the user, is the device managed and patched, is this access allowed right now. Employees reach internal applications from anywhere, without a VPN, through an access proxy. This idea, zero trust network access (ZTNA), is now offered by many vendors and is gradually replacing remote-access VPNs in large companies.
A second trend keeps the VPN but changes its shape. Mesh VPNs such as Tailscale, Netbird or the open-source Headscale build WireGuard tunnels directly between every pair of devices, instead of sending everything through one central gateway. A central service only distributes keys and access rules, often tied to the company's single sign-on. The result feels like one flat private network across laptops, servers and clouds, with access rules per device and per user.
Site-to-site VPNs between offices, data centres and clouds will stay. Remote access is moving towards identity-based access, where the question is not "is this device inside the network?" but "should this user on this device reach this application?".
12. Should You Use a VPN?
A short decision guide:
- You need to reach a private network (company systems, a home server, a cloud network without public access): yes, that is exactly what a VPN is for. WireGuard or a mesh VPN is the simplest choice today.
- You work on untrusted networks (hotels, airports, conferences): useful. HTTPS protects the content, but a VPN hides which sites you visit and protects apps with weak TLS.
- You do not want your ISP or a local network to see your browsing: yes, if you trust the VPN provider more than your ISP.
- You want to appear in another country (streaming, prices, censorship): yes, that works, within the provider's terms and the law of your country.
- You want to be anonymous: no. A VPN provider knows who you are and where you connect. Use Tor.
- You want protection from tracking, malware or phishing: no. Use a good browser, an ad and tracker blocker, updates and a password manager.
13. Conclusion
From leased lines to WireGuard, the idea behind the VPN has stayed the same for thirty years: put private traffic inside encrypted packets and send them across a public network. What changed is how simple and fast it has become, and how clearly we now understand its limits.
- A VPN is a tunnel: encapsulation, encryption and authentication between two points.
- Routing decides what goes into the tunnel; DNS and IPv6 decide whether something leaks past it.
- WireGuard made VPNs small, fast and hard to misconfigure; IPsec remains the standard between networks.
- A VPN moves trust to whoever runs the server. It does not make you anonymous and does not stop tracking.
- For companies, the VPN gateway is a prime target, and zero trust is replacing the idea of a trusted inside.
If you have a server of your own, set up WireGuard with the two configuration files from section 6. In ten minutes you will have a private network of your own, and you will see exactly what a VPN does.
Sources and Further Reading
- S. Kent, R. Atkinson, RFC 2401: Security Architecture for the Internet Protocol, 1998; S. Kent, K. Seo, RFC 4301, 2005.
- C. Kaufman et al., RFC 7296: Internet Key Exchange Protocol Version 2 (IKEv2), 2014.
- K. Hamzeh et al., RFC 2637: Point-to-Point Tunneling Protocol (PPTP), 1999.
- B. Schneier, Mudge, D. Wagner, "Cryptanalysis of Microsoft's PPTP Authentication Extensions (MS-CHAPv2)", 1999.
- M. Marlinspike, D. Hulton, "Divide and Conquer: Cracking MS-CHAPv2 with a 100% Success Rate", DEF CON 20, 2012.
- J. A. Donenfeld, "WireGuard: Next Generation Kernel Network Tunnel", NDSS Symposium, 2017: https://www.wireguard.com/papers/wireguard.pdf
- R. Ward, B. Beyer, "BeyondCorp: A New Approach to Enterprise Security", ;login:, December 2014.
- OpenVPN project: https://openvpn.net/community/
- CISA, Known Exploited Vulnerabilities Catalog: https://www.cisa.gov/known-exploited-vulnerabilities-catalog




