We may earn a commission when you buy through links on our site. This never affects our rankings. How we test →

BestVPNRanked

How Does a VPN Work? Tunnels, Encryption and Protocols Explained

A step-by-step look at what happens when you connect to a VPN: tunnelling, encryption, protocols, DNS and kill switches.

Last updated:

3 min read

The big picture

Without a VPN, your device sends data to your router, then to your internet service provider, which passes it on across the internet to the website or service you want. Each step along the way can see where your data is going, and the network operators can see a lot about your activity.

With a VPN, your device first wraps your data in an encrypted package and sends it to the VPN server. The server unwraps it and forwards it to its destination. Replies come back the same way in reverse. To everyone between you and the VPN server, your traffic looks like a single encrypted stream to one address.

What happens when you press connect

  • Authentication: the app proves to the VPN server that you have a valid account, and the server proves to your app that it is genuine.
  • Key exchange: your device and the server agree on encryption keys for this session, without ever sending the keys in a form others could use.
  • Tunnel creation: a virtual network interface is set up on your device, and your operating system is told to send traffic through it.
  • DNS switch: the app tells your device to use the VPN provider's DNS servers, so the names of sites you look up don't leak to your normal provider.
  • Traffic flows: from now on, data is encrypted before it leaves your device and decrypted only at the VPN server.

Encryption in simple terms

Encryption turns readable data into what looks like random noise. Only someone with the right key can turn it back. Modern VPNs use well-studied ciphers such as AES-256 or ChaCha20. Both are considered secure when implemented correctly, and neither is realistically breakable with today's technology.

VPNs also protect the integrity of your data. Each package carries a check that reveals any tampering on the way, so an attacker on public Wi-Fi cannot quietly change what you send or receive.

VPN protocols

A protocol is the set of rules your device and the server use to build and run the tunnel. The protocol affects speed, battery use and how well the connection survives switching between networks.

  • WireGuard: a modern, compact protocol known for high speeds and quick connections. Many providers now build their own versions on top of it.
  • OpenVPN: a long-established, open-source protocol. It is very configurable and widely audited, though often a little slower.
  • IKEv2/IPsec: fast and good at reconnecting when your phone moves between Wi-Fi and mobile data.

Most people can leave the app on its automatic setting. If you have problems on a restrictive network, trying a different protocol is often the fix.

Why your IP address changes

An IP address is like a return address on a letter. Because the VPN server forwards your requests, websites see the server's IP address. That is why a VPN can make you appear to be in another country: the site sees a server located there.

Many users share the same server address at the same time, which makes it harder to link activity on that address to one person.

Kill switches and leak protection

A VPN only protects traffic that goes through the tunnel. If the connection drops, your device may quietly fall back to your normal connection. A kill switch prevents this by blocking all traffic until the VPN reconnects.

Leaks are the other risk. DNS leaks happen when site lookups bypass the VPN. IPv6 leaks occur when a VPN only handles older IPv4 traffic. WebRTC, a browser feature for calls, can sometimes reveal your real address. Good VPN apps block all three by default, and we test for each of them.

Why a VPN can slow you down

Encryption takes a little processing power, and your data travels an extra distance to the VPN server. On a nearby server with a modern protocol, the slowdown is usually small. Connecting to a server on another continent adds more delay. This is why we measure speeds on both short and long-distance connections.

Related guides