How a VPN Works in Simple Terms: 3 Steps for Every Packet

Ilya Sokolov

8 min readBasics

Packet in the tunnel

Every packet that leaves a device with a VPN on goes through 3 steps before it reaches the network. The app captures it, encrypts it and wraps it in a new packet addressed to a server. The server unwraps the original, decrypts it and forwards it to the site from the server’s own IP address.

How a VPN works in simple terms: capture, encryption and wrapping

Without a VPN, your phone sends each packet straight to the site. The packet header holds 2 addresses, yours and the site’s. The data follows the header. With a VPN on, the app handles the packet first.

  1. Capture. When you connect, the app creates a virtual network interface. It also adds a route that sends all traffic into that interface. Your browser, messengers, games and background services all send their packets there. Our guide to what a VPN is explains where this interface comes from.
  2. Encryption. The app encrypts the whole packet, including the site’s address. AES-GCM and ChaCha20-Poly1305 belong to the AEAD class of ciphers. They compute an authentication tag along with the ciphertext, so the server rejects any packet that was changed in transit.
  3. Wrapping. The encrypted packet is placed inside a new one as its data. The new packet goes from your device to the VPN server. Network standards call this step encapsulation.

The server runs the 3 steps backward. It removes the outer header, verifies the authentication tag, decrypts the original packet and puts its own address on it in place of yours. The site replies to the server’s address. The server encrypts and wraps the reply and returns it to the app. To the browser, the reply looks as if it came straight from the site.

The keys are agreed before the first packet

Before any data moves, the app and the server perform a handshake. First, each side checks the other. The app has to confirm that the real server is answering and not an impostor. Then both sides derive shared session keys.

The keys themselves never cross the network. Each side picks a secret number and sends the other side only a public value calculated from it. Each side combines its own secret with the other side’s public value. Both arrive at the same key. Someone who captures both public values still cannot calculate that key. This method is called Diffie-Hellman key exchange. TLS 1.3, which protects HTTPS sites, uses it, and so do most VPN protocols.

Session keys last for one session only. A new connection gets new keys.

The protocol decides how the handshake and the packets look from outside. In Ben's VPN, the 4 protocols are VLESS + REALITY, XHTTP, Hysteria2 and Shadowsocks, and the app picks the one that fits your network. There is nothing to switch by hand. Our article on VPN protocols compares them.

What a packet shows with and without a VPN

Take a request to an HTTPS site over hotel Wi-Fi. The table lists what the hotel network or your internet provider can read in that packet.

Packet detailWithout a VPNWith a VPN
Destination addressThe site’s IP addressThe VPN server’s IP address
Source addressYour public IP addressYour public IP address, as before
DNS lookup before the site opensPasses through the provider, often unencryptedTravels inside the tunnel to the server
Site name at the start of an HTTPS connectionUsually readable as plain textEncrypted with the rest of the packet
Timing and volumeVisible for each site separatelyVisible only as a total for one server
Packet sizeNormalA few dozen bytes larger because of the second header

The table leaves the provider 3 facts. The device exchanges data with one server, the exchange happens at a certain time, and a certain amount of data moves. Which sites the server talks to after that is not in the packet. Some networks try to spot VPN traffic by indirect signs. If a protocol stops getting through on your network, the app switches to a different one without your help.

A tunnel has 2 addresses, one private and one public

When you connect, the app assigns the virtual interface an internal address. It usually comes from a private range such as 10.x.x.x. Private addresses are not routed on the internet. Sites never see the internal address, and it has no country.

Sites see a different address. It is the public IP address of the server where your traffic exits to the internet. Sites use it to guess your country, language and local ads. A new location changes this public address.

Addresses and apps you send around the tunnel still reach the internet from your usual address. The section on split tunneling below shows how to choose them.

Ben's VPN main screen on Windows with the selected location and the Location, Tunnel and Support buttons
Ben's VPN main screen on Windows. Below the server card are the “Location”, “Tunnel” and “Support” buttons.

How a VPN compares with a proxy in 5 everyday situations

A proxy also relays traffic through another server, but it works at a different level. It accepts connections from individual programs, not packets from the whole device. The difference shows up in the most ordinary actions.

SituationVPNRegular proxy (HTTP, SOCKS5)
You open a site in the browserThe request goes to the server encryptedThe request reaches the proxy if the browser settings name it, and only the site’s own HTTPS encrypts it
A messenger updates in the backgroundIts traffic goes through the tunnel tooThe messenger goes online directly unless the proxy is set in the messenger itself
A program asks DNS for a site’s IP addressThe DNS query travels in the tunnelDepends on the program and the proxy type
You make a call or play over UDPThe packets go through the tunnelHTTP proxies do not carry them. SOCKS5 can, but not every program uses it
A page without HTTPS opensThe site sees the server’s address, and the provider cannot read the pageThe page is readable on the way, and some HTTP proxies add your address in the X-Forwarded-For header

The main consequence is reach. A proxy covers only what you point at it. A VPN captures packets at the system level and does not depend on the settings of each program. Our VPN vs proxy comparison covers proxy types and their limits.

Split tunneling sends part of the traffic around the tunnel

You can narrow the “all traffic into the tunnel” route. The app then asks the system to send some addresses over your regular connection. In Ben's VPN, the “Tunnel” button opens “Split tunneling” with 3 modes.

  • “Off”. All device traffic goes through the VPN.
  • “For Russia”. Traffic to Russian services goes directly, and the rest goes through the VPN.
  • “Manual”. The IP addresses, subnets and domains you enter go directly.

Android adds a list called “Apps that bypass the VPN”. Apps on that list skip the tunnel completely. A changed mode applies from the next connection, so reconnect after switching.

A typical case is a work portal or a government site in your own country that may refuse visitors from foreign addresses. Put its domain in “Manual” and reconnect. The site then sees your usual address, while everything else stays in the tunnel.

Speed depends on the route, not the cipher

Encryption adds little delay. Most modern processors speed up AES in hardware, and ChaCha20 runs fast without such support. Three things set your speed with a VPN: the distance to the server, the load on the server and the quality of your own network.

Every packet travels to the server and back, and a more distant server means a longer trip. Multihop adds one more server to the route. The app turns it on by itself when the connection is unstable or fails without it. If the country does not matter to you, choose “Fastest” in the “Change Location” window. The app then picks a location near you. Our article on ping in games shows how distance turns into delay.

A second VPN takes the route from the first

Capture, the first step above, depends on one route that sends all traffic into the interface. Two VPN apps cannot own that route at the same time. That is why Android allows one VPN connection at a time, and a second VPN app disconnects the first when it starts. A computer does not stop the second client. Both keep changing the same routes and DNS settings, and packets end up in one tunnel or the other.

Questions and answers

Can my internet provider see which sites I visit through a VPN?

No, provided your DNS lookups also travel inside the tunnel. The provider sees a connection to one server, its timing and the total amount of data.

Can intercepted VPN traffic be decrypted?

Not without the session key. The app and the server derive that key on their own, and it never travels over the network. Anyone who intercepts the traffic sees the server address, timing and volume, but not the content.

Which IP address does a website see when I use a VPN?

The public address of the server in your chosen location. The internal tunnel address stays hidden. Sites you send around the tunnel with split tunneling see your usual address.

What is the internal IP address that appears after I connect a VPN?

It is the address of the virtual interface the app creates. It usually comes from a private range such as 10.x.x.x, and private addresses are not routed on the internet. Sites never see it. They see the server’s public address.

Does a VPN use more data?

A little more. Every packet gets a second header, which adds a few dozen bytes. With video and downloads, where packets are large, the difference is hard to notice. With many small packets, it is larger.

Does encryption slow down my internet?

Hardly. Most modern processors speed up AES in hardware, and ChaCha20 is fast without such support. Your speed with a VPN depends on the distance to the server, its load and your own network.

Written by

Ilya Sokolov

Writes about VPN basics in plain words.

Start for 3 days, then decide

The trial costs $0.50 and opens all 187 countries and every app.

Mac App Store App Store Google Play