Network Services and Security · Topic 5 of 7
IPsec VPNs
Describe IPsec remote access and site-to-site VPNs: IKE, ESP and AH, tunnel and transport modes, and the show commands that prove a tunnel is up.
- 5 min
- IPsec gives confidentiality, integrity, authentication and anti-replay.
- Site-to-site joins two networks through gateways, with no client software.
- Remote access connects one user with a VPN client.
What it is
A virtual private network (VPN) protects traffic across a network you do not trust, and IPsec is the standard framework that does it.
Traffic is wrapped and encrypted, so it travels as though it were on a private line. Anyone who captures it on the way sees only scrambled data.
IPsec provides four things:
- Confidentiality: the data is encrypted so it cannot be read.
- Integrity: the receiver can tell if the data was changed in transit.
- Authentication: each side proves who it is.
- Anti-replay: copies of old packets that an attacker replays are rejected.
How it works
Two peers agree on keys with IKE, then protect the data with ESP or AH in tunnel or transport mode.
Two types of VPN
Site-to-site VPN. Two gateways, such as routers or firewalls, build a tunnel between two networks. Users and servers behind each gateway run no VPN software. The gateway encrypts traffic as it leaves and the other gateway decrypts it. The tunnel is usually permanent, and it joins a branch office to a head office without a leased line.
Remote access VPN. One user connects from outside, such as from home or a hotel. The user's computer runs a VPN client, and the tunnel is built between that computer and a gateway at the organization. It is created when needed and ended when finished. Remote access can use IPsec or SSL/TLS, which runs in a browser or client app and passes through most firewalls easily.
If users run no VPN software, it is site to site. If one person connects with a client, it is remote access.
IKE sets up the keys
The Internet Key Exchange (IKE) protocol lets the peers agree on how to protect traffic and exchange keys safely. It uses UDP port 500.
- Phase 1 builds a secure management channel. The peers authenticate with a pre-shared key or digital certificates, and use a Diffie-Hellman exchange to create a shared secret without ever sending it.
- Phase 2 builds the IPsec security associations (SAs), the agreed rules and keys for the data traffic.
IKE version 2 reaches the same result with a different, shorter set of message exchanges.
The IPsec protocols
| Protocol | IP protocol number | Encrypts | Integrity and authentication |
|---|---|---|---|
| ESP, Encapsulating Security Payload | 50 | Yes | Yes |
| AH, Authentication Header | 51 | No | Yes |
ESP is used in nearly all VPNs because it provides encryption. AH authenticates the whole packet but hides nothing, so it is rarely used alone. AH also cannot pass through NAT, because NAT changes the addresses it protects.
Tunnel mode and transport mode
The mode decides what is protected and how the packet is wrapped.
| Tunnel mode | Transport mode | |
|---|---|---|
| Protects | The whole original IP packet | Only the payload |
| IP header | New outer header added | Original header kept |
| Typical use | Site-to-site VPNs between gateways | Between two hosts, or end to end |
| Original addresses | Hidden | Visible |
Tunnel mode is the normal choice when gateways protect traffic for other hosts, because the private addresses stay hidden inside the encrypted packet.
Algorithms and NAT
Encryption uses a cipher such as AES. Integrity uses a hash such as SHA. Both ends must be set to compatible choices, and a stronger Diffie-Hellman group gives a stronger key exchange.
When a peer sits behind NAT, IPsec has a problem, because NAT changes addresses and ports. NAT traversal wraps ESP packets in UDP, using UDP port 4500.
Proving a tunnel works
You are asked to describe IPsec, not to build it, but know the show commands that prove a tunnel is up.
R1# show crypto isakmp sa
R1# show crypto ikev2 sa
R1# show crypto ipsec sa
The first two show the IKE security associations, version 1 and version 2. show crypto ipsec sa shows the IPsec SAs and counters for packets encrypted and decrypted. If the encrypted counter rises but the decrypted counter stays at zero, the other side is not sending traffic back, or the return traffic is being lost on the way.
AH authenticates but never encrypts. If a question needs confidentiality, the answer is ESP.
Common mistakes
Saying AH encrypts. AH authenticates only. ESP encrypts.
Mixing up the two VPN types. Site-to-site joins networks. Remote access joins a person.
Choosing transport mode for a gateway tunnel. Gateways use tunnel mode so the original packet is hidden.
Thinking a VPN makes a device safe. A VPN protects data in transit, not an infected device.
Forgetting NAT. IPsec through NAT needs NAT traversal on UDP 4500.
Treating the tunnel as a firewall. Traffic that arrives through a tunnel still needs to be filtered.
What to remember for the exam
- IPsec gives confidentiality, integrity, authentication and anti-replay.
- Site-to-site joins two networks through gateways, with no client software.
- Remote access connects one user with a VPN client.
- IKE negotiates keys on UDP 500. Phase 1 builds the channel, phase 2 builds the IPsec SAs.
- ESP is protocol 50 and encrypts. AH is protocol 51 and does not.
- Tunnel mode protects the whole original packet and adds a new header.
- Transport mode protects only the payload and keeps the original header.
- NAT traversal uses UDP 4500.
Check yourself
Who runs VPN software in a site-to-site VPN compared with a remote access VPN?
In site to site the two gateways build the tunnel and users run nothing. In remote access the user's computer runs a VPN client.
What is the difference between ESP and AH?
ESP is IP protocol 50 and provides encryption, integrity and authentication. AH is protocol 51 and authenticates but does not encrypt.
What is the difference between tunnel mode and transport mode?
Tunnel mode protects the whole original IP packet and adds a new IP header. Transport mode protects only the payload and keeps the original header.
Topic 5 of 7 in Network Services and Security
Test yourself on Network Services and Security
The full Cisco CCNA 200-301 v2.0 question bank has 1,242 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Cisco. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.