Sub topic 10
Internet VPNs with IPsec: private traffic over a public network
This chapter assumes you know IPv4 addressing, basic routing, and how to read router CLI. You should also know what a WAN is and how a leased line or MPLS service differs from the public internet.
Why use an internet VPN
A leased line or MPLS circuit gives you a private path, but it costs more per megabit and takes weeks to install. A broadband internet link is cheap and quick to get, but it is shared and public. An internet VPN closes that gap. It builds an encrypted tunnel across the internet, so two sites can exchange private traffic as if they had a direct link.
IPsec is the usual standard for this. It is a suite of protocols that provides three things:
- Confidentiality: the payload is encrypted, so outsiders cannot read it.
- Integrity: tampering with a packet is detected.
- Authentication: each peer proves who it is before the tunnel comes up.
How an IPsec tunnel is built
Two routers (or firewalls) negotiate in two phases. The names below follow IKEv1. IKEv2 does the same work with different message names.
- Phase 1 (IKE SA): the peers authenticate each other, using a pre-shared key or certificates. They agree on encryption and hashing algorithms and run a Diffie-Hellman exchange to derive shared keys. The result is a secure control channel.
- Phase 2 (IPsec SA): over that channel, the peers agree on parameters for the data traffic. They create one security association (SA) for each direction.
After this, user packets travel inside ESP (Encapsulating Security Payload), the IPsec protocol that encrypts and authenticates data.
Tunnel mode and transport mode
IPsec has two modes.
| Mode | What is protected | Typical use |
|---|---|---|
| Tunnel | The whole original IP packet is encrypted and wrapped in a new IP header | Site-to-site VPNs between routers or firewalls |
| Transport | Only the payload is protected, and the original IP header stays | Host-to-host traffic, or traffic that is already tunneled, such as GRE |
Site-to-site WAN links normally use tunnel mode. The new outer header carries the public addresses of the two VPN devices. The inner packet keeps the private addresses of the sites.
Common problems
- Reduced MTU: ESP adds overhead, so a full-size 1500-byte packet no longer fits. Fragmentation or dropped packets follow. Lower the tunnel MTU or adjust TCP MSS.
- Mismatched proposals: if the two peers do not share an encryption, hash, or DH group, phase 1 fails.
- NAT in the path: ESP has no port numbers, so a NAT device can break it. NAT traversal (NAT-T) wraps ESP in UDP port 4500 to fix this.
- Plain IPsec does not carry routing protocols or multicast well. Designs often run GRE inside IPsec, or use virtual tunnel interfaces, so that OSPF or BGP can run across the tunnel.
Where it fits
IPsec over broadband suits small branches, backup links for an MPLS circuit, and sites where a private circuit is not available or affordable. Its weakness is that the underlay is best effort, and each tunnel must be configured and managed. Many tunnels across many sites become hard to maintain by hand. SD-WAN, covered later, builds on IPsec tunnels and adds central control and path selection.
Exercise
A branch router builds an IPsec tunnel to headquarters, and small packets pass but large file transfers stall. Name the likely cause and one fix.
Show answer
ESP encapsulation adds overhead, so full-size packets exceed the path MTU and are fragmented or dropped. Lower the tunnel interface MTU or clamp the TCP MSS (for example, with ip tcp adjust-mss) so packets fit after encapsulation.
Exercise
Why is tunnel mode used for site-to-site VPNs rather than transport mode?
Show answer
Tunnel mode encrypts the entire original packet, including its private source and destination addresses, and adds a new outer header with the public addresses of the VPN devices. The sites' private addresses are therefore hidden and can cross the internet.