FSD-Motors

    IPSec Explained: Protocols, Modes, IKE & VPN Security

    Surbhi Suhane
    December 3, 2025
    IPSec

    IPSec refers to a comprehensive suite of protocols and standards developed by the Internet Engineering Task Force (IETF) to secure communication across a network at the Internet Protocol (IP) layer. This technology is indispensable for building secure Virtual Private Networks (VPNs) and ensuring end-to-end data safety.

     

    In simple words, IPSec is the technical framework that adds essential security features—such as encryption and authentication—directly to the data packets traveling over the internet. 

     

    Without this protocol suite, sensitive information would be exposed to various security threats during transmission. In this section, we will discuss the core architecture, components, and operational modes of IPSec.

     

    What is Internet Protocol Security (IPSec)?

    IPSec is defined as a set of cryptographic protocols that work at Layer 3 of the Open Systems Interconnection (OSI) model, known as the network layer. Its primary function is to provide security services on a per-packet basis. This means that security measures are applied to each individual IP data packet as it moves from the source to the destination.

     

    The introduction of IPSec became necessary because the original Internet Protocol (IPv4) was designed without built-in security features. This design omission meant that data packets could be intercepted, read, or modified by unauthorized parties. 

     

    The security services provided by IPSec are applied independently of the application using the IP connection, offering a robust, system-wide layer of protection.

     

    IPSec achieves its goals by utilizing two fundamental protocols: the Authentication Header (AH) and the Encapsulating Security Payload (ESP). Additionally, it relies on the establishment of a logical connection called a Security Association (SA) to define the necessary security parameters between communicating peers.

     

    Get Started with IPSec!

     

    Core Protocols of IPSec

    The IPSec framework is built upon two distinct yet complementary protocols. These protocols can be used separately or together to provide different levels of security for the data traffic. Both protocols involve adding a new header or a new header and a trailer to the standard IP packet structure.

     

    Authentication Header (AH)

    The Authentication Header (AH) protocol provides integrity and authentication for data packets. AH ensures that the data received at the destination has not been tampered with while in transit, and it verifies that the data originated from the claimed sender.

     

    • AH does not provide confidentiality, meaning the data within the packet remains readable.
    • Instead, AH calculates a cryptographic checksum (a hash or Hashed Message Authentication Code, HMAC) over the IP header and the data payload.
    • This calculated value is placed in the AH field.
    • When the receiving device gets the packet, it performs the same calculation.
    • If the local calculation matches the received AH value, the integrity is verified.

     

    Encapsulating Security Payload (ESP)

    The Encapsulating Security Payload (ESP) protocol is the most commonly used component of IPSec. ESP can provide both confidentiality (encryption) and optional authentication/integrity services.

     

    • ESP works by encrypting the data payload—the actual information being sent—to ensure confidentiality.
    • This encryption makes the packet unreadable to any unauthorized entities that intercept it.
    • To secure the packet further, ESP can also append authentication data, similar to the AH, but this authentication covers the encrypted payload and the ESP trailer, not the entire original IP header.
    • Because it offers both data privacy and authentication, ESP is often preferred over AH for most network security deployments, especially for creating a secure VPN tunnel.

     

    Also Read: Unified Endpoint & Network Investigation: CrowdStrike and SentinelOne Stories in the Stories Workbench

     

    Key Security Services Provided by IPSec

    The suite of IPSec protocols works in harmony to deliver four critical security services necessary for protecting digital communications. These services are the foundation of any secure network communication.

     

    IPSec enables security services that protect data traffic at the IP layer.

     

    • Confidentiality (Encryption): This service ensures that the contents of a data packet are kept private from eavesdroppers. IPSec uses standardized encryption algorithms, such as the Advanced Encryption Standard (AES), to scramble the data. Only the intended recipient, who possesses the correct decryption key, can successfully read the original information.

       

    • Data Integrity: Integrity ensures that the data has not been altered or modified in any way during its transmission. IPSec achieves this by using keyed hash algorithms (like HMAC) to create a unique digital signature for the packet. If even a single bit of the packet is changed, the recipient's calculated hash will not match the one included in the packet, signaling a potential attack.

       

    • Data Origin Authentication: This service verifies the identity of the sender. It confirms that the data truly originated from the authorized source and not from an impostor. This protection is vital to prevent unauthorized entities from injecting false information into the communication stream.

       

    • Anti-Replay Protection: A common attack involves an unauthorized party capturing a legitimate data packet and retransmitting it later to confuse or disrupt the network. IPSec prevents this by using sequence numbers assigned to each packet within a Security Association (SA). The receiving system tracks these numbers and discards any received packets with duplicate or old sequence numbers.

     

    Concept of Security Association (SA)

    In the architecture of IPSec, a fundamental concept is the Security Association (SA). A Security Association is not a protocol itself but rather a logical, one-way connection that defines the set of parameters necessary for a secure communication channel between two entities.

     

    What happens is that for any two peers to communicate securely using IPSec, they must agree on several security settings. These settings—which include the protocol (AH or ESP), the encryption algorithm, the authentication algorithm, the keys to be used, and the lifetime of the connection—are all bundled together and referred to as an SA.

     

    • SAs are unidirectional. This means that if two computers want to communicate securely in both directions, two SAs must be established: one for data flowing from A to B, and a second for data flowing from B to A.
    • Each SA is uniquely identified by three elements: the Security Parameter Index (SPI), the IP destination address, and the IPSec protocol being used (AH or ESP).
    • The SPI is a unique numerical index found in the AH or ESP header that allows the receiving device to know which set of security parameters to apply to the incoming packet.

     

    Also Read: Unified Device Visibility: Enhancements to Cato’s Device Inventory

     

    IPSec Modes of Operation

    IPSec is highly versatile because it can operate in one of two modes, which determine how the security headers (AH or ESP) are applied to the IP packet. The choice between these two modes depends on the security environment and the purpose of the connection.

     

    Transport Mode

    In Transport Mode, IPSec provides protection primarily for the upper-layer protocols, such as TCP or UDP, that exist above the IP layer.

     

    • Transport Mode is typically used for host-to-host secure communication.
    • The IPSec header (AH or ESP) is inserted between the original IP header and the upper-layer protocol header.
    • The original IP header is kept intact.
    • This mode does not hide the IP addresses of the source and destination, meaning a third party can still observe who is communicating.

     

    Tunnel Mode

    Tunnel Mode is the standard mode for building secure VPNs and is the most widely deployed. This mode is typically used for gateway-to-gateway communication, such as between two routers connecting two separate corporate networks.

     

    • In Tunnel Mode, the entire original IP packet (including its headers and data) is completely encapsulated and protected.
    • A new IP header is added to the front of the packet.
    • The security protocol (AH or ESP) is applied to the original, inner packet.
    • This new header contains the IP addresses of the IPSec gateways (the routers), effectively masking the internal addresses of the private network.
    • This provides a high degree of security and confidentiality for the network structure itself.

     

    Comparison Chart: Transport Mode Vs. Tunnel Mode

    Basis for ComparisonTransport ModeTunnel Mode
    Meaning (Scope of Protection)This mode secures the upper-layer payload (e.g., TCP, UDP, ICMP) of the IP packet. The protection is applied strictly between the two end-hosts and does not involve any intermediary routers for security processing.This mode secures the entire original IP packet—including the original IP header and the data payload—by treating it as the data payload for a new, outer IP packet. The original packet is encapsulated (tunneled).
    Header Modification & StructureThe IPSec header (AH or ESP) is inserted after the original IP header and before the transport layer segment. The original source and destination IP addresses remain intact and visible in the outer (only) IP header.The IPSec header (AH or ESP) is inserted between the original IP packet and a newly created, outer IP header. The entire original packet is now the data for the new packet, securing its contents.
    End-points & Traffic FlowUsed for host-to-host communications. The endpoints for the IPSec Security Association (SA) are the source and destination hosts themselves. The traffic is usually encrypted end-to-end.Used for gateway-to-gateway (e.g., site-to-site VPNs) or host-to-gateway (e.g., remote access VPNs) communications. The SA endpoints are typically the security gateways (routers/firewalls) protecting the networks, not the end-hosts.
    IP Address Visibility & AnonymityThe original source and destination IP addresses are exposed because they are in the primary, unencrypted header. This allows intermediary devices (like firewalls) to inspect the addresses but reveals the private endpoints.The original, internal IP addresses are hidden because they are part of the encapsulated, protected packet. The outer, visible IP header contains only the addresses of the two IPSec gateways.
    Key Use & Typical DeploymentIdeal for securing application data between two specific servers or a client and a server within a private environment, or when the IP header information is necessary for network functionality.The industry standard for creating Virtual Private Networks (VPNs) across public networks (like the internet). It is used to securely connect two geographically separated networks or a remote user to a corporate network.
    Firewall & NAT CompatibilityCan be problematic with Network Address Translation (NAT) devices if the AH protocol is used, as AH authenticates the IP header, which NAT changes. ESP is generally more compatible, but still requires careful configuration.Is generally more compatible with NAT devices, particularly when using ESP, because the outer IP header (containing the gateway addresses) can be modified by NAT without invalidating the integrity check of the inner (original) protected packet.

     

    Key Management with Internet Key Exchange (IKE)

    Before any secure data can be transmitted using IPSec, the two communicating peers must establish a Security Association (SA) and agree on the cryptographic keys they will use. The process of managing these keys and establishing the SAs is handled by a separate but integrated protocol called the Internet Key Exchange (IKE).

     

    IKE is a protocol that uses a secure method to automatically negotiate, create, and manage the cryptographic keys required for the IPSec SAs. While keys could be configured manually, this is not scalable or secure for large networks. IKE automates the entire process, making the deployment of complex IPSec environments practical.

     

    IKE Phases

    The IKE protocol operates in two distinct phases to establish the necessary security infrastructure.

     

    IKE Phase One

    The goal of IKE Phase One is to establish a secure, authenticated communication channel, known as the IKE Security Association (IKE SA) or Phase 1 SA. This tunnel is used solely to protect the negotiation of the Phase Two SAs.

     

    • IKE Phase One authentication can occur using pre-shared keys, digital signatures (certificates), or sometimes usernames and passwords.
    • The result of this phase is a single, bidirectional, and authenticated tunnel between the two peers. This tunnel provides a protected pathway for the next phase of negotiation.

     

    IKE Phase Two

    The goal of IKE Phase Two is to negotiate the specific IPSec Security Associations (IPSec SAs) that will protect the actual user data traffic. These are the SAs that utilize the AH or ESP protocols.

     

    • Within the secure IKE SA established in Phase One, the peers quickly negotiate the specific parameters for data protection, such as the exact encryption and authentication algorithms (e.g., AES-256, SHA-256).
    • The result of this phase is the creation of two separate, unidirectional IPSec SAs—one for each direction of data flow—which are used to secure the user's traffic until they expire.

    This two-phased approach separates the complex, long-lived key exchange (Phase One) from the negotiation of the shorter-lived, data-specific session keys (Phase Two), offering both efficiency and enhanced security.

     

    Also Read: Reducing Network Latency and Enhancing User Experience Globally with Cato SASE

     

    Advantages and Disadvantages of IPSec

    Like any advanced technical solution, IPSec provides significant benefits but also presents certain implementation challenges. Understanding these facets is essential for any network design decision.

     

    Advantages

    • Robust Security: IPSec provides a high level of security by offering authentication, integrity, and confidentiality at the network layer, which is crucial for sensitive data.
    • Application Transparency: Since it operates at the IP layer, it can secure virtually any application running over IP without needing modification to the application software.
    • Standardization: As an IETF standard, IPSec is interoperable across hardware and software from different vendors, ensuring flexibility in network design.
    • Scalability for VPNs: The use of Tunnel Mode is the de facto standard for building scalable and strong VPNs, especially in connecting remote office networks.

     

    Disadvantages

    • Complexity: The initial setup and configuration of IPSec require a deep understanding of its various components, protocols, and modes (AH, ESP, IKE, SA, Transport, Tunnel).
    • Overhead: The addition of new headers and the process of encryption and decryption introduce processing and bandwidth overhead on the participating devices. This can sometimes lead to reduced network performance if the hardware is not powerful enough.
    • Firewall Conflicts: Because IPSec uses specific protocols (AH uses IP protocol 51; ESP uses IP protocol 50) and sometimes obscures the transport layer information, it can sometimes conflict with traditional firewall and Network Address Translation (NAT) devices. This requires careful configuration to ensure compatibility.

     

    Conclusion

    In a nutshell, Internet Protocol Security (IPSec) is far more than just a single protocol; it is a meticulously designed framework that protects IP communications. It systematically addresses the major vulnerabilities of the original Internet Protocol by weaving together a set of cryptographic tools. 

     

    By defining clear Security Associations (SAs) and automating key management through the Internet Key Exchange (IKE), IPSec establishes a reliable, secure channel. The choice between Transport Mode for host-to-host security and Tunnel Mode for building robust Virtual Private Networks (VPNs) ensures that IPSec can meet a wide range of network security requirements. 

     

    All in all, for anyone serious about transmitting sensitive data across an untrusted network like the internet, a thorough implementation of this standardized security suite is an absolute necessity.

     

    Talk to Our Cato SASE experts today!

     

    IPSec

     

    Key Takeaways

    • IPSec is a suite of protocols that provides security services at the Internet Layer (Layer 3) on a per-packet basis.
    • The two main protocols are Authentication Header (AH) for integrity and authentication, and Encapsulating Security Payload (ESP) for confidentiality and optional authentication.
    • A Security Association (SA) is a set of security parameters that defines a one-way secure connection between two entities.
    • Transport Mode secures data between two hosts, while Tunnel Mode secures the entire IP packet and is used for VPNs.
    • The Internet Key Exchange (IKE) protocol is responsible for the automatic creation and management of the cryptographic keys used by IPSec.
    • The primary services offered are Confidentiality, Data Integrity, Data Origin Authentication, and Anti-Replay Protection.

     

    FAQs on IPSec

    What is the primary function of IPSec?

    The primary function of IPSec is to provide security services like confidentiality (encryption), data integrity, and authentication at the Internet Protocol (IP) layer (Layer 3). It is most commonly used for establishing secure Virtual Private Networks (VPNs).

     

    What is the main difference between the AH and ESP protocols?

    The core difference is encryption. The Authentication Header (AH) provides authentication and integrity but does not encrypt the data. The Encapsulating Security Payload (ESP) provides encryption (confidentiality) and optional authentication, making it the more widely used protocol.

     

    Which OSI layer does IPSec operate on?

    IPSec operates at the Network Layer (Layer 3). Operating at this layer means it can secure traffic for almost any application running over IP without the need to modify the application itself.

     

    When is Tunnel Mode preferred over Transport Mode?

    Tunnel Mode is preferred for securing traffic between two networks (e.g., gateway-to-gateway VPNs). It encapsulates the entire original IP packet and adds a new header, hiding the internal network addresses. Transport Mode is used for host-to-host security where only the data payload is encrypted.

     

    What is a Security Association (SA)?

    A Security Association (SA) is a unidirectional logical connection that defines the set of parameters needed for secure communication between two peers. These parameters include the specific protocol (AH or ESP), the cryptographic algorithms, and the keys to be used.

     

    What is the role of IKE in the IPSec framework?

    The Internet Key Exchange (IKE) protocol's role is to automatically negotiate, create, and manage the cryptographic keys and the Security Associations (SAs) required for the IPSec connection. This automation is crucial for scalability and security.

     

    What four security services does IPSec deliver?

    IPSec delivers Confidentiality (encryption), Data Integrity (verifying data hasn't changed), Data Origin Authentication (verifying the sender's identity), and Anti-Replay Protection (preventing malicious retransmission of packets).

    IPSec Explained: Protocols, Modes, IKE & VPN Security

    About The Author

    Surbhi Suhane

    Surbhi Suhane is an experienced digital marketing and content specialist with deep expertise in Getting Things Done (GTD) methodology and process automation. Adept at optimizing workflows and leveraging automation tools to enhance productivity and deliver impactful results in content creation and SEO optimization.

    Like This Story?

    Share it with friends!

    Subscribe to our newsletter!

    share your thoughts