What is IPsec (Internet Protocol Security)?

What is IPsec (Internet Protocol Security)?

Imagine sending a secret message across a crowded room—without anyone else being able to read it. That’s exactly what IPsec does for your data on the internet. In a world full of cyber threats, IPsec (Internet Protocol Security) acts like a digital bodyguard, keeping your information safe and private as it travels online. But how does it actually work? Let’s break it down in simple terms.

Table of Contents

What is IPsec?

IPsec (Internet Protocol Security) is used to secure sensitive data as it travels over the network, such as financial transactions, medical information, and business communications. IPsec tunneling is also used to protect virtual private networks (VPNs), where it encrypts all data exchanged between two endpoints. IPsec may also encrypt application layer data and protect routers providing routing data over the public internet. IPsec can also be used to offer authentication without encryption, such as confirming that data came from a recognized sender.

Encryption at the application or transport levels of the Open Systems Interconnection (OSI) paradigm enables protect data transmission without the need for IPsec. Encryption is performed at the application layer through Hypertext Transfer Protocol Secure (HTTPS). Encryption is provided at the transport layer by the Transport Layer Security (TLS) protocol. However, encrypting and authenticating at these higher layers increases the risk of data leakage and attackers intercepting protocol information.

In this blog, we’re going to dig up about the IPsec and you will get to know about IPsec uses and working.

How does IPsec Operate?

IPsec operates in five phases. They are as follows:

How does IPsec Operates

1. Recognize the Host

When a host system decides that a packet needs protection and should be delivered using IPsec rules, the IPsec process starts. Such packets are considered “interesting traffic” for IPsec reasons, and they engage security restrictions. This shows that the necessary authentication and encryption are applied to departing packets. The host system confirms that an incoming packet’s encryption and authentication have been done properly when it deems it to be interesting.

2. IKE Phase 1 or Negotiation

The hosts utilize IPsec to discuss the rules for a secured circuit during the second phase. Additionally, they confirm one another and provide a secure channel between them via which they may agree on how the IPsec circuit would encrypt or authenticate data sent over it.

  • Primary Mode: The host making the connection offers suggestions for its preferred methods of authentication and encryption. Negotiation continues until both hosts agree and create an IKE Security Association (SA) that specifies the IPsec circuit they will use. This mode offers a secure channel for data transmission and is safer than aggressive mode.
  • Aggressive Mode: The initiating host forbids negotiation and mandates the use of the IKE SA. The session is authenticated when the responding host accepts the request. Hosts can easily build an IPsec circuit using this method.

3. IKE Phase 2 or IPsec Circuit

Step 3 involves creating an IPsec circuit over the security gateway created in IKE Phase 1. The IPsec hosts agree on the data transmission algorithms to be used. Additionally, the hosts decide on and distribute decryption and encryption keys for communication to and from the secured network. The hosts also transmit different numbers known as cryptographic nonces, which are required to authenticate connections.

4. IPsec Transit

Through the secure channel they have built in the fourth stage, the hosts actually exchange data. The packets are encrypted and decoded using the previously set IPsec Security Associations (SAs).

5. Termination of IPsec

The IPsec tunnel is finally terminated. Generally, this occurs after a specified volume of data has passed over the IPsec tunnel or after the transaction has expired. The hosts communicate when one of these events takes place, and the link is cut off. After the data transmission has terminated, the hosts delete the private keys that were utilized.

Architecture of IPsec

The IPSec (IP Security) architecture utilizes two protocols to protect traffic or data transfers. These protocols are ESP and AH (Encapsulation Security Payload) (Authentication Header). The IPSec Architecture includes protocols, algorithms, DOI, and key management. All of these components are required to provide the three key services:

  • Confidentiality
  • Authentication
  • Integrity
Architecture of IPsec

1. Architecture

The fundamental principles, definitions, protocols, algorithms, and security requirements of IP Security technology are covered in IP Security Architecture.

2. Encapsulation Security Payload

The secrecy service is provided by ESP (Encapsulation Security Payload). The Encapsulation Security Payload can be implemented in two ways:

  • ESP with optional authentication
  • ESP combined with authentication

3. Encryption algorithm

The encryption algorithm is a document that details the different encryption techniques used for Encapsulation Security Payload.

4. AH Protocol

The AH Protocol (Authentication Header) enables both authentication and integrity. The Authentication Header is used in just one way: Authentication and Integrity.

5. Authentication Algorithm

The authentication Algorithm is a set of files that define the authentication algorithm used for AH and the authentication option of ESP.

6. DOI (Domain of Interpretation)

A DOI is an identifier that can be used with both the AH and ESP protocols. It comprises values that are required for documentation and are connected to one another.

7. Key Management

The key management document outlines how keys are shared between sender and recipient.

What are IPsec Protocols?

Data packets traveling across IPv4 and IPv6 networks are authenticated and encrypted using IPsec. The Internet protocol of a packet contains IPsec protocol headers, which govern how information in a packet is treated, including delivery and routing along a network. A number of additional elements, such as security data and one or more cryptographic techniques, are added to the IP header by IPsec.

A protocol in networking is a predefined method of structuring data so that any networked machine may comprehend it. IPsec is a protocol suite, not a single protocol. The IPsec suite consists of the following protocols:

1. IP Authentication Header (AH)

  • Defined in: RFC 4302
  • Function: Provides services for transport security and data integrity.
  • Purpose: AH was intended to be included in such an IP packet in order to add authentication information while simultaneously shielding the contents from alteration.

2. Encapsulating Security Protocol (ESP)

  • Function: Encrypts both the IP header and the payload for each packet.
  • Transport Mode Exception: In transport mode, ESP only encrypts the payload.
  • Operation: ESP appends its header and trailer to each data packet.

3. Internet Security Association and Key Management Protocol (ISAKMP)

  • Defined in: RFC 7296 and IKE protocol
  • Function: Enables the establishment of a Security Association (SA) for encrypted packet exchange at the IP layer.
  • Capabilities:
    • Establishment of keys
    • User authentication
    • Definition of Security Associations (SAs)

Note:
ISAKMP defines the security parameters that control communication between two hosts or systems. Every SA specifies a one-way connection between two hosts. All connection-related details—cryptographic method, IPsec mode, encryption key, and other factors affecting data transit—are contained in the SA.

4. Internet Key Exchange (IKE)

  • Defined in: RFC 7296
  • Function: Allows two systems or devices to create a secure communication channel across an untrusted network.
  • Purpose: Used to create a safe tunnel between a client and server via which encrypted communication is delivered.
  • Security Mechanism: Uses a series of key exchanges based on the Diffie-Hellman key exchange.

IPsec uses or is utilized by a large number of other protocols, including digital signature techniques and most of the protocols included in the IPsec and IKE Document Pathway, as defined in RFC 607.

Get 100% Hike!

Master Most in Demand Skills Now!

What is the Purpose of IPsec?

  • IPsec is used to encrypt sensitive data traveling over networks, including banking transactions, health information, and corporate conversations.
  • Additionally, IPsec tunneling is used to safeguard virtual private networks (VPNs), which encrypt all data transferred between two endpoints.
  • Additionally, IPsec may provide security for networks relaying routing information across the open internet and encrypt application layer traffic.
  • IPsec can also be employed to provide identification without encrypting, such as when confirming the identity of the sender of data.
What is the Purpose of IPsec?
  • Instead of using IPsec, data transmission can be secured using encrypting at the service or transport layers of the Open Systems Interconnection (OSI) paradigm.
  • Through Hypertext Transfer Protocol Secure(HTTPS), encryption is carried out at the application layer.
  • At the transport layer, the Transport Layer Security (TLS) protocol offers encryption.
  • On the other side, encryption and authentication at these upper layers raise the danger of data loss and attackers eavesdropping on protocol data.

What is IPsec VPN?

In its most basic form, a VPN is a secure network that is installed over a public site. Anyone with a VPN connection has the same level of access to the private network as someone who is physically connected to it. Businesses frequently use VPNs to give staff remote access to the company network.

A VPN that employs IPsec as its protocol to provide secure connections between devices is known as an IPsec VPN. SSL/TLS and L2TP are two other IPsec VPN protocols. Let’s have a look at these various IPsec protocols:

  • Transport Layer Security (TLS) is the successor to Secure Sockets Layer (SSL), which is a cryptographic IPsec protocol that provides communication security over a computer network. TLS is well recognized for providing security over HTTPS communications.
  • Internet Protocol Security (IPsec) is a secure network protocol that is used in VPNs to authenticate and encrypt data packets to offer secure communication.
  • Layer Tunneling Protocol (L2TP) is a tunneling protocol that is used to enable VPNs. L2TP does not provide robust authentication on its own. IPSec is frequently used to secure L2TP packets. The combination of these two protocols is known as L2TP/IPsec.

What are the IPsec Modes?

IPSec can be set to function in two modes: tunnel and transport. The use of each mode is determined by the IPSec specifications and implementation.

What are the IPsec Modes?

1. Transport Mode

In Transport Mode, only the payload (the actual data) of the IP packet is encrypted and/or authenticated. The IP header stays untouched. This mode is mostly used for end-to-end communication between two devices, like two computers or servers, because it keeps the original IP addressing intact.

  • Use Case: Secure communication between two endpoints (e.g., client to server).
  • Key Point: Only the data part is protected, not the whole packet.

2. Tunnel Mode

Tunnel Mode encrypts and/or authenticates the entire IP packet, including the header. Then, a new IP header is added to the front. This makes the original packet completely hidden from outsiders. It’s commonly used for network-to-network communications, such as in VPNs.

  • Use Case: Site-to-site VPNs or connecting two networks securely.
  • Key Point: The Entire original packet is protected and hidden.

IPsec vs WireGuard vs OpenVPN: A Simple Comparison

FeatureIPsecWireGuardOpenVPN
TypeProtocol suiteModern VPN protocolSSL/TLS-based VPN
SecurityMature and strongVery strong (modern crypto)Strong (via OpenSSL)
SpeedGood, but can be slowerVery fastModerate
Setup ComplexityComplexVery simpleModerate
CodebaseLargeVery small (~4,000 lines)Large
PortUDP 500/4500UDP 51820 (default)TCP/UDP 1194 (varies)
Platform SupportExcellentGood (growing)Excellent
Best UseEnterprise, site-to-siteLightweight, general useRemote access, customizable
StabilityVery stableNewer, still maturingVery stable
EncryptionAES, 3DES (configurable)ChaCha20, Poly1305 (built-in)OpenSSL (many options)
Battery Use (Mobile)HighVery lowModerate

Uses of IPsec

If you’re wondering where and how IPsec is used in the real world, you’re not alone. Many IT decision-makers and network professionals search for this exact answer before implementing it. IPsec (Internet Protocol Security) is trusted by businesses and government organizations to protect sensitive data as it travels over the internet or private networks.

Here are some of the most common and important IPsec use cases:

1. Connecting Branch Offices (Site-to-Site VPN)

Use case: A company has multiple office locations (like HQ and regional offices) and needs to share data securely between them.

  • How IPsec helps: IPsec creates a secure “tunnel” between routers or firewalls at both sites using site-to-site VPN.
  • Why it matters: Employees in different offices can securely access files, apps, and systems as if they were in the same building.

2. Secure Remote Access for Employees

Use case: Employees working from home or while traveling need secure access to the company network.

  • How IPsec helps: With IPsec remote access VPN, users can connect to the network over public Wi-Fi without risking data leaks.
  • Why it matters: It keeps corporate data protected even when accessed outside the office.

3. Government Communications and Classified Data

Use case: Government agencies need to securely send confidential or classified data between departments or field offices.

  • How IPsec helps: IPsec encrypts data and verifies sender identity, making sure sensitive information doesn’t fall into the wrong hands.
  • Why it matters: National security and public safety rely on secure and private communication channels.

4. Securing Routers and Network Devices

Use case: ISPs or large enterprises need to protect routing updates and communication between routers.

  • How IPsec helps: IPsec ensures that only verified routers can exchange routing data and protects it from tampering.
  • Why it matters: Prevents man-in-the-middle attacks and route hijacking.

5. Industrial and SCADA System Security

Use case: Utilities and industrial companies need to secure remote control systems and sensors.

  • How IPsec helps: IPsec encrypts data sent between central control rooms and remote devices in SCADA systems.
  • Why it matters: Helps protect critical infrastructure like power plants, water treatment, and oil pipelines from cyber threats.

IPsec VS SSL

IPsecSSL
Internet protocol security (IPsec) is a group of protocols that offer security for the Internet Protocol.SSL is a secure protocol designed for securely transmitting data over the Internet.    
It operates at the OSI model’s Internet Layer.It operates between the OSI model’s transport and application layers.
IPsec is used to secure a VPN.SSL is used to protect online transactions.
For implementation, changes to the operating system are necessary. The application does not require any changes.No modifications to the operating system are necessary for implementation; however, changes to the application are required.
IPsec is used to operate the system space.SSL is located in user space.

Conclusion

Authenticity, confidentiality, and message integrity are all guaranteed by the standard set of protocols known as IPsec, which is used to secure internet connections. Implementations don’t call for modifications to the upper-layer protocols or applications because it offers a transparent end-to-end encrypted channel. It is a mature protocol suite that supports a wide range of encryption and hashing algorithms, is exceedingly scalable, and is interoperable while having substantial drawbacks because of its complexity.

About the Author

Lead Penetration Tester, Searce Inc

Shivanshu is a distinguished cybersecurity expert and Penetration tester. He specialises in identifying vulnerabilities and securing critical systems against cyber threats. Shivanshu has a deep knowledge of tools like Metasploit, Burp Suite, and Wireshark.