Sub topic 3
What a VPN adds to a tunnel
This chapter assumes you know IP addressing and routing tables, the difference between TCP and UDP, and the idea from the previous chapter that a tunnel puts one packet inside another.
A tunnel is not yet private
A tunnel wraps an inner packet in an outer packet. This lets the inner packet cross a network that does not route the inner addresses. A plain tunnel such as GRE does only that. Anyone on the path can read the inner packet and change it. They can also send forged outer packets, and the receiver will accept them as if they came from the far end.
A virtual private network (VPN) is a tunnel plus security guarantees and a way to set them up. The tunnel moves the packets. The VPN decides who may use it and what an observer can learn from it.
The properties a VPN adds
| Property | Question it answers | Without it |
|---|---|---|
| Authentication | Who is at the other end? | Anyone can send packets to the endpoint and have them accepted. |
| Integrity | Was the packet altered in transit? | An on-path attacker can edit packets unnoticed. |
| Confidentiality | Can someone else read the contents? | Inner packets travel as readable text. |
| Replay protection | Is this an old packet sent again? | A captured packet can be re-sent later. |
| Key management | How do both ends get fresh secrets? | Keys are typed in by hand and rarely changed. |
Later chapters explain how IPsec, TLS-based VPNs and WireGuard provide each property. For now, remember that a VPN is a combination of these properties and a tunnel.
Two common shapes
- Site-to-site: Two gateways, for example one at each office, connect two networks. Hosts behind them send ordinary packets and do not know a VPN exists. The gateways add and remove the protection.
- Remote access: A single device, such as a laptop, connects to a gateway. The device runs VPN software that creates a virtual network interface. The gateway gives that interface an inner address.
Following one packet
Suppose a laptop with inner address 10.8.0.2 wants to reach an internal server at 10.0.0.5.
- The routing table sends traffic for 10.0.0.0/24 to the virtual interface.
- The VPN software takes the inner packet and encrypts it. It adds an integrity check and a sequence number for replay protection.
- It places the result in an outer packet, often UDP, addressed to the gateway's public address.
- The internet routes the outer packet like any other traffic.
- The gateway checks the integrity tag and the sequence number. If both pass, it decrypts the packet and forwards the inner packet to 10.0.0.5.
The reply takes the same path in reverse. Routing is still ordinary routing. The VPN changes what the packet looks like on the wire and who may inject packets, not how the routing table works.
Authentication decides who gets in
Encryption alone is not enough. If a laptop encrypts traffic to an attacker who is pretending to be the gateway, the attacker reads everything. A VPN therefore authenticates the peer, with a pre-shared key, a certificate or a public key, before it trusts the tunnel. The next chapters on key exchange show how this works.
Exercise
A GRE tunnel and a VPN both carry inner packets inside outer packets. Name two security properties a VPN adds, and describe an attack on a plain GRE tunnel that each one prevents.
Show answer
Examples: authentication stops an attacker from sending forged outer packets that the endpoint accepts as coming from the peer. Integrity stops an on-path attacker from altering inner packets unnoticed. Confidentiality stops an observer from reading the inner contents. Replay protection stops a captured packet from being re-sent later.