Skip to content

IPsec VPN Explained

Network switches and cables in a server rack
Photo: Shixart1985, via Wikimedia Commons (CC BY 2.0). IPsec protects traffic at the network layer, below individual apps.

An IPsec VPN is a VPN built on IPsec, a set of internet standards that encrypts and authenticates every IP packet between two points, such as your laptop and your company gateway, or two office networks. It works at the network layer, so it can protect all of a device’s traffic rather than a single app.

Network switches and cables in a server rack
Photo: Shixart1985, via Wikimedia Commons (CC BY 2.0). IPsec protects traffic at the network layer, below individual apps.

What Is IPsec?

IPsec stands for Internet Protocol Security. It is not one protocol but a suite of protocols, standardised by the Internet Engineering Task Force (IETF), that protects data as it travels across IP networks. The framework provides four things: encryption, so packet contents become unreadable ciphertext; integrity checks, so the receiving side can confirm data arrived unchanged; authentication, so each endpoint proves it is the machine it claims to be; and anti-replay protection, so packets an attacker captured earlier and sent again are rejected.

Your data does not cross the internet as one piece. It is broken into packets, each wrapped in addressing information so routers know where to send it. IPsec works on those packets individually, at the network layer. That position is what makes it different from a browser-based VPN: because it sits below the apps, email clients, file transfers, and backups travel the same protected path as browser traffic, and software does not have to know a VPN exists.

A VPN built on these protocols is an IPsec VPN. In consumer VPN apps it usually shows up under the name IKEv2, which is the key exchange protocol that sets the connection up. Our guide to VPN protocols compares IPsec with OpenVPN and WireGuard, and our guide to how does a VPN work explains the tunnel an IPsec VPN creates.

The Three Parts of IPsec

IPsec has three components, each with its own job.

ESP (Encapsulating Security Payload) encrypts the payload of each packet and checks that nobody changed it on the way. Practically every IPsec VPN in use today uses ESP. It is the part that does the actual protecting.

AH (Authentication Header) checks integrity and origin across the payload and most of the IP header, but it does not encrypt anything. AH leaves your data readable to anyone who captures it, and it breaks when NAT sits in the path, because it protects parts of the IP header that NAT rewrites. Home routers and mobile networks use NAT, so AH is rarely used.

IKE (Internet Key Exchange) is how the two sides prove who they are and agree on keys and settings. IKEv2 is the current version. IKEv1 was formally deprecated by the IETF in 2023 and moved to historic status, so any setup still running IKEv1 should be treated as legacy.

The record of the settings and keys both ends agree on is called a security association (SA). It is the shared rulebook for that tunnel: which cipher, which integrity check, which keys, and how long they stay valid.

How Does an IPsec VPN Work?

An IPsec VPN sets up its protected tunnel in four stages.

  1. Authentication and negotiation. The endpoints prove their identity to each other, using either a pre-shared key, a secret password both sides already hold, or a digital certificate issued by a trusted authority. They then settle on the encryption and integrity algorithms they will use and the keys that go with them. IKE runs this stage, and it normally runs over UDP port 500.
  2. Tunnel establishment. With the terms agreed, both sides open the protected connection and record the agreed settings as a security association.
  3. Encryption and transmission. Outbound packets are encrypted and encapsulated before they leave the device, then cross the internet like any other traffic. If the device sits behind a router doing NAT, both sides switch to NAT Traversal (NAT-T), which wraps the key exchange and the encrypted traffic in UDP port 4500 so they cross the router unaltered.
  4. Decryption at the destination. The receiving endpoint checks each packet for tampering, decrypts it, and passes the original data on.

IKE itself works in two phases. Phase 1 builds the secure control channel between the peers, using main mode with six messages. Phase 2 then negotiates the security association that actually protects user traffic. User data always travels under Phase 2, never Phase 1. The two phases also handle rekeying, the scheduled swap to fresh keys partway through a session.

A Raspberry Pi sitting on a network switch
Photo: RAIL P (RAIL.PHOTOGRAPHY), via Wikimedia Commons (CC0). IKE negotiates the connection; ESP then encrypts every packet that follows.

Tunnel Mode vs Transport Mode

IPsec can protect traffic in two ways, and the difference is how much of each packet gets wrapped.

Tunnel modeTransport mode
Protected dataThe entire original IP packetThe packet payload only
IP headerOriginal header hidden inside; a new outer header is addedOriginal header kept and visible
Typical useVPN connections between devices and networksDirect host-to-host traffic inside a data center

Tunnel mode wraps the whole original packet, headers included, inside a new encrypted packet with a new outer header. Anyone watching a tunnel-mode connection sees traffic moving between the two endpoints, not the addresses hidden inside. It is the mode used by most VPN connections.

Transport mode encrypts only the payload and leaves the original IP header visible, which suits direct server-to-server traffic where the endpoints are the machines themselves. In transport mode the source and destination stay in plain view, since only the payload is encrypted.

IKEv2: The Version You Will Actually Meet

IKEv2 is the key exchange protocol in common use today, and it is the reason IPsec survives in consumer VPN apps. It negotiates more safely than IKEv1, rekeys more cleanly, and adds MOBIKE, which keeps an established tunnel running when your device’s IP address changes. A phone moving from Wi-Fi to mobile data stays connected instead of dropping and rebuilding the tunnel, which is why IKEv2 is the default IPsec choice on mobile devices.

IKEv2 is also built into Windows, macOS, and iOS, so you may be using it without having chosen it. When a VPN app lists IKEv2 as a protocol option, it means IKEv2/IPsec: IKEv2 sets up the connection and IPsec protects what goes through it. They are two halves of one setup, not two competing protocols. Consumer apps are slowly moving away from it, though: Proton VPN is retiring IKEv2 by February 2027, and Private Internet Access dropped it on iOS in October 2026.

Most current setups pair AES for encryption with HMAC-SHA-2 for integrity. HMAC-SHA-2 produces a short fingerprint of the data using a secret key, so any tampering shows up immediately. Older setups sometimes still run DES or MD5, neither of which is considered sound now, and some legacy hardware still offers 768- or 1024-bit Diffie-Hellman groups, which provide less protection than modern configurations. As a home user you do not pick these settings yourself; your VPN app or your employer’s IT team does. What matters is that the software is current and still getting updates, since that is what keeps the ciphers and key exchange modern.

Close-up of server racks in a data center
Photo: panumas nikhomkhai, via Pexels. Enterprise IPsec deployments live in rooms like this, where gateways at each site terminate the tunnels.

Site-to-Site vs Remote Access IPsec VPNs

IPsec VPNs come in two shapes, and the shape decides what sits at each end of the tunnel.

A site-to-site IPsec VPN links whole networks together. A company with a head office and a warehouse across town puts a gateway at each end, and the tunnel runs between those two points. A printer in the warehouse can reach a server at head office without any VPN software on the printer itself, because the gateway handles encryption for everything behind it. Our guide to site-to-site VPN covers this setup in detail.

A remote-access IPsec VPN connects a single device to a whole network. Client software on your laptop forms one end of the tunnel, and the gateway on your office network forms the other, so that same server is reachable from a hotel room whenever the tunnel is up. Our guide to remote access VPN explains how the client side works.

Rows of server racks in a data center
Photo: NOIRLab/NSF/AURA/T. Slovinský, via Wikimedia Commons (CC BY 4.0). Site-to-site IPsec links whole networks through gateways at each end.

IPsec VPN vs SSL VPN

The most common comparison for business buyers is IPsec against SSL VPN, and the difference is the layer each one works at.

IPsec works at the network layer, so when the tunnel is up the device behaves as though it were plugged directly into the remote network. All of its traffic can be routed through the protected tunnel. An SSL VPN works higher up, using TLS, the technology that encrypts your connection to a banking site. A browser-based SSL VPN typically opens a portal to a defined set of resources, such as an intranet page or a single internal application, and the device itself never joins the network. Some SSL VPNs do run a client and carry all traffic like IPsec, so the portal version is not the only kind.

The practical trade-off is access against convenience. IPsec needs matching configuration at both ends, even where the client is already built into the operating system. A browser-based SSL VPN can often run with nothing installed, and its traffic goes over TCP port 443, the same port used for HTTPS traffic, which is widely permitted across networks and firewalls. That can make SSL VPNs easier to use on restrictive networks, such as hotel or airport Wi-Fi, where IPsec traffic may be blocked. Our guide to SSL VPN covers the SSL side in full.

Advantages and Disadvantages of IPsec

IPsec has been deployed since the 1990s, so its trade-offs are well documented.

Advantages. It offers strong encryption and authentication when configured with current settings. Its network-layer coverage protects every app on the device, not just the browser. It is application independent, which is why decades-old business applications run over IPsec without modification. And it is a published IETF standard, so equipment from different vendors can interoperate.

Disadvantages. Configuration is complex, with dozens of settings that must match at both ends. Every packet gains extra bytes from encryption and encapsulation, which can cause fragmentation on links with a smaller maximum packet size. Some networks block the ports IPsec relies on, or handle address translation poorly, which can prevent a connection from forming at all.

IPsec is secure when it is configured with current settings. The checks that matter are simple: IKEv2 rather than IKEv1, AES rather than DES or 3DES, SHA-2 rather than MD5, and software that is still receiving updates.

Network switches and patch panels in a rack
Photo: Dsimic, via Wikimedia Commons (CC BY-SA 4.0). IPsec’s strength is also its weakness: both ends must agree on dozens of settings before the tunnel comes up.

Watch: Master the Power of IPSec VPN

Master the Power of IPSec VPN: Your Ultimate Guide to Secure Networking

A home Wi-Fi router on a desk
Photo: Hayden Schiff, via Wikimedia Commons (CC BY 4.0). NAT traversal is what lets IPsec tunnels pass through home routers, wrapping the traffic in UDP port 4500.

FAQs

What is an IPsec VPN?

An IPsec VPN is a VPN built on IPsec, a set of IETF standards that encrypts and authenticates every IP packet between two points. It works at the network layer, so it protects all of a device’s traffic, and it is commonly used for site-to-site links between offices and for remote access to company networks.

What is the difference between IPsec and IKEv2?

IPsec is the suite that encrypts and authenticates the traffic. IKEv2 is the key exchange protocol that sets the connection up: it handles authentication and negotiates the keys and settings, which are recorded as a security association. When a VPN app offers IKEv2, it means IKEv2/IPsec together.

What is the difference between tunnel mode and transport mode?

Tunnel mode wraps the entire original packet, headers included, inside a new encrypted packet, and it is the mode used by most VPN connections. Transport mode encrypts only the payload and leaves the original IP header visible, which suits direct host-to-host traffic inside a data center.

Which ports does IPsec use?

IKE negotiation normally runs over UDP port 500. When NAT traversal is needed, the key exchange and the encrypted traffic switch to UDP port 4500. ESP itself is IP protocol 50. A firewall that blocks these will stop an IPsec tunnel from forming.

Is IPsec still secure?

Yes, when configured with current settings: IKEv2, AES encryption, and SHA-2 integrity checks, on software that still receives updates. IKEv1 was deprecated by the IETF in 2023, and older ciphers such as DES and MD5 are no longer considered sound. Security depends on the configuration, not just on the name IPsec.

Is IPsec better than SSL VPN?

It depends on the use. IPsec gives a device full network-level access to a remote network, which suits site-to-site links and remote workers. SSL VPNs are often easier to use, because a browser-based SSL VPN needs nothing installed and its traffic passes over TCP port 443, which most firewalls already allow.

Sources

6

Every factual claim on this page was verified against a named source above.

More VPN guides

Sofia Lindqvist

Written by

Sofia Lindqvist Privacy & VPN Writer

Sofia's byline covers the privacy side of VPNs: jurisdiction, data-retention law and VPN use while travelling. Articles are based on the text of laws and regulator pages, provider transparency reports and official support documentation. Legal topics are explained in plain language and are information, not legal advice.

Umar Attique Shah

Reviewed by · November 30, 2026

Umar Attique Shah Editor & Reviewer

Umar is the editor of this site and the person responsible for what is published on it. He is an SEO consultant and WordPress developer who has built and managed content websites since 2019. After an article is published he checks it against its sources, its structure and the editorial rules on our Editorial Process page, with the help of AI-assisted checks.

How our articles are researched, reviewed and updated