šŸ”Œ What is an ENI (Elastic Network Interface) in AWS?


Generated image

An Elastic Network Interface (ENI) is a virtual network card that can be attached to an EC2 instance in a VPC (Virtual Private Cloud). It allows the instance to connect to the network and can carry multiple IP addresses, security groups, and MAC address.


🧩 Key Components of an ENI:

  • Primary private IP address
  • One or more secondary private IP addresses
  • One Elastic IP (optional, for public access)
  • One or more security groups
  • MAC address
  • Description and tags

šŸŽÆ Why Use ENIs?

Use Case Benefit
Multiple ENIs per instance Enables separation of traffic (e.g., frontend/backend)
Move ENIs between instances Fast failover / disaster recovery
Attach to Lambda or ECS with ENI Enable VPC networking
Create virtual appliances ENIs act like virtual firewalls, routers, etc.

šŸ“¦ Types of ENIs:

Type Use Case
Primary ENI Comes attached to EC2 by default
Secondary ENI Manually attach for extra traffic routing or HA setup

šŸ› ļø CLI Example: Create and Attach ENI

# Create an ENI
aws ec2 create-network-interface --subnet-id subnet-abc123 --groups sg-12345678

# Attach ENI to instance
aws ec2 attach-network-interface --network-interface-id eni-12345678 --instance-id i-0abcdef1234567890 --device-index 1


šŸ”„ ENI in Failover:

You can detach an ENI from a failed instance and reattach it to a standby instance – this retains the IP address and network configuration, providing minimal disruption.

Back to blog

Leave a comment