linkedin Skip to Main Content
Just announced: CoderPad Play! Engage your team with fun technical challenges.
Back to blog

Internet Key Exchange: What It Is and How It Works


Internet communication is an integral part of our daily lives, with data and information packets being sent and received over the internet on a constant basis. Often, these packets contain private and confidential data that should only be seen, read, and understood by the sender and the intended recipient. Because of this, there’s a need to protect individual personal data and privacy. 

Encryption is one such measure that is usually put in place in order to safeguard people’s privacy and the security of their data. However, there is a protocol or mechanism already set up to handle the encryption, hashing, authentication, and decryption of data transmitted over the internet. And that protocol is IPSec, which is a suite of protocols for securing network connections. As a matter of fact, IPSec not only offers confidentiality of data but also ensures the following: 

  • Data received by a host is from an authenticated user only (i.e., authentication).
  • Data received has not been tampered with during transmission (i.e., verification).

In this article, you’ll learn about the following: 

  • The Internet Key Exchange protocol, which is used to establish IPSec security associations (often abbreviated as SAs) to ensure secure, authenticated communication between two devices over the internet
  • How IKE works in two phases to negotiate security parameters and establish a secure channel
  • The role of IKE in IPSec in providing encryption and integrity protection for data transmitted over a network
  • Best practices and common pitfalls to avoid while setting IKE protocol

What is Internet Key Exchange?

Internet Key Exchange (often abbreviated as IKE) is a standard protocol for setting up a secure and authenticated transmission mechanism for two entities to communicate in a network. In other words, it’s a protocol used to set up SA in the IPSec protocol suite. You can establish IKE between the following: 

  • a pair of hosts
  • a pair of security gateways
  • a host and security gateway

How does IKE work?

IKE works in two phases. These two phases are IKE Phase I and IKE Phase II. Let’s dive into the details of what happens in each phase mentioned above. 

IKE Phase I

The main purpose of this phase is to establish an IKE SA that can be used to establish multiple IPSec SAs to use in Phase II. In other words, the main goal of this phase is to establish secure, authenticated communication between the parties. 

In this phase, the two parties negotiate the security protocols and algorithms and then agree upon the one to use to secure the communication. The Diffie–Hellman key exchange algorithm is used to establish a shared secret key. This shared secret key is used to encrypt further communication between the two parties—because it is important to protect the negotiation of the SA itself. 

The communication can be authenticated using any of these mechanisms: 

  • pre-shared secret key
  • public key encryption
  • digital signature

This phase has two modes of operation: 

  • aggressive mode
  • main mode

Once Phase I is complete, the established IKE SA is then used to negotiate IPSec SAs (the algorithms and other security parameters) in Phase II. 

Note: The difference between the main mode and the aggressive mode is that in the main mode, the identity of the parties and the hash of the shared secret key are protected, while the aggressive mode does not protect this information. 

IKE Phase II

This phase works similarly to the Phase I protocol. However, its main purpose is to set up the IPSec SAs. In this phase, the two parties send messages and agree on a set of security parameters to use in SAs using the IKE SA created in Phase I (e.g., which cryptographic algorithm to use for hashing, authentication, or encryption). 

Once the security associations have been set up, data can then be exchanged securely between them. The data is encrypted using the keys that have been negotiated, and the parties use these keys to decrypt the data upon receipt. The keys used in this phase can be formed in two ways: 

  • without PFS (short for Perfect Forward Secrecy)
  • with PFS

You’ll learn about the importance of using keys with PFS in the vulnerability and best practices section. 

Note: Unlike Phase I, which can operate in either of the two modes, Phase II can only operate in one mode, which is the quick mode. 

What is IKE used for?

IKE is an important component or part of the IPSec architecture. As such, it plays a vital role in ensuring secure communication between two parties on the internet. The following are the uses for IKE in the IPSec architecture: 

  1. IKE prevents several types of attacks:
  2. IKE can be used to automate building and managing SAs. Security associations can be built and managed in two ways:
    • Static: In this case, a system administrator needs to establish and manage SAs manually. This isn’t practical for a large network.
    • Dynamic: In this case, establishing and managing SAs is automated. This is what the IKE protocol does.

Advantages of using IKE

The following are the advantages of using IKE: 

  1. Reliability
  2. Secrecy and authenticity
  3. Scalability (suitable for big networks)
  4. Privacy and anonymity (protecting the identity of parties in the protocol); it should be noted that VPNs make use of this IKE feature

Disadvantages of using IKE

The following are the disadvantages of using IKE: 

  1. Complexity: IKE can be quite difficult to set up and maintain as it requires technical know-how of encryptions and authentication that can be complex to configure and manage.
  2. Resource intensive: As a result of the complexity associated with IKE, it requires a lot of resources to set up. These resources are costly as well, especially in large networks. This might be a concern for large networks with limited resources and budgets.
  3. Limited compatibility: Some devices and operating systems (especially older and nonstandard devices) do not support IKE. This can limit its use in certain environments or make it difficult to integrate with existing infrastructure.

Examples  applications of IKE 

IKE is often used as the underlying protocol in the following networks or connections: 

  1. Virtual Private Network (often abbreviated as VPN)
  2. Secure Shell Connection (SSH)
  3. Secure File Transfer Protocol (SFTP)
  4. Secure-site-to-site connection

Vulnerabilities in IKE

As with every security approach, it is important to recognize that nothing is 100% perfect. IKE is no exception. It certainly has some flaws, which are listed below: 

  • Password guessing: The use of low entropy passwords makes IKE susceptible to offline dictionary attacks.
  • Susceptible to MITM-based downgrade attacks.
  • Susceptible to replay attacks.
  • Key reuse: It’s likely for a single key to be used for more than one session between two parties, which is a bad thing and makes the communication vulnerable to attacks.

Prevention of Vulnerabilities in IKE

The vulnerabilities mentioned above can be prevented in the following ways: 

  • Use a strong password: It’s advisable to use a high entropy (unique and unguessable) password so as to avoid offline dictionary attacks.
  • Use Perfect Forward Secrecy: PFS can help prevent key reuse by generating new keys for each session.
  • Use a firewall: A firewall can help to protect against threats and attacks such as MITM and DoS attacks by setting the right security rules.
  • Regularly update software: Update software on a regular basis to avoid known vulnerabilities.
  • Set up two-factor authentication: Two-factor authentication provides an extra layer of security by ensuring a user provides other means, either through code or tokens, to authenticate themselves aside from using a username and password.
  • Use segregation of systems: Carefully segregate client systems onto multiple service access points with stricter configurations.
  • Use anti-replay measures: Configure IKE to use measures such as sequence number or timestamp to avoid replaying old packets (replay attacks).

By following these best practices, it’s possible to reduce the risk of vulnerabilities in IKE and improve the security of a network using this protocol. 


IKE is an important protocol for establishing secure internet connections and many different applications make use of it. It is an essential component of contemporary cybersecurity since it helps to ensure the confidentiality, integrity, and authenticity of data exchanged between devices. 

However, it is important to be aware of the potential vulnerabilities in IKE mentioned and take steps to prevent them. Check out this article about open-source security if you’re interested in learning more about the field of cybersecurity. 

This post was written by Boluwatife Fayemi. Boluwatife is a Full Stack Web Developer, proficient in Javascript, Python, and their frameworks. His curiosity makes him explore and gain knowledge about a variety of topics. Boluwatife is passionate about teaching and writing, and this makes writing technical articles an enjoyable process for him.