AWS -Elastic Network Interfaces (ENI)

Nidhi Ashtikar
4 min readJul 10, 2024

--

Elastic Network Interfaces (ENIs) are logical networking components within a Virtual Private Cloud (VPC) in AWS. They function as virtual network cards, providing network connectivity for EC2 instances and other AWS services.

Attributes of an ENI

Each ENI must have a primary private IPv4 address from the VPC’s IPv4 address range.

ENIs can have one or more secondary private IPv4 addresses. This is useful for applications requiring multiple IP addresses on a single instance.

You can associate one or more Elastic IP addresses (IPv4) with a primary or secondary private IP address on the ENI.

ENIs can also have IPv6 addresses if your VPC supports IPv6.

Each ENI has a unique MAC address, which is crucial for network communication.

ENIs can have one or more security groups attached. Security groups act as virtual firewalls to control inbound and outbound traffic to the ENI.

ENIs support resource-based permissions policies. This means you can control who can attach or detach the ENI from instances.

Key Benefits of ENIs :

You can attach multiple ENIs to an EC2 instance, enabling complex network configurations such as different subnets or security groups on a single instance.

In case of instance failure, you can move an ENI from one instance to another, maintaining the same network configurations (IP addresses, security groups).

ENIs simplify the management of network configurations and IP addresses, making it easier to manage network settings independently from the instance lifecycle.

Practical Uses of ENIs :

ENIs are used by network load balancers to distribute incoming traffic to multiple targets.

For critical applications, ENIs can be moved between instances to ensure high availability and quick recovery from instance failures.

By attaching different ENIs with different security groups to the same instance, you can segment network traffic and apply different security rules.

Note: They are bound to specify AZ (Availability Zone)

Steps to Practice ENIs

Launch Two EC2 Instances:

  • Choose Amazon Linux 2 and t2.micro instance type.
  • Select a key pair (any will do).
  • Use an existing security group (e.g., launch-wizard-1).
  • Launch two instances.

Check Network Interfaces:

  • Go to Instances under the EC2 dashboard.
  • Select each instance, and go to the Networking tab.
  • Check the Network Interfaces section to see the attached ENIs.
  • Each instance has an ENI with a primary private IPv4.

Create a New Network Interface:

  • Click Create network interface.
  • Set Description
  • Select a Subnet (same AZ as instances, e.g., us-east-1c).
  • Enable Auto-assign private IPv4.
  • Attach a Security group.
  • Click Create network interface.

Attach New ENI to an Instance:

  • Select the newly created ENI.
  • Click Actions > Attach.
  • Choose an instance to attach it to (e.g., the first instance).
  • Confirm attachment.
  • Check the instance’s Networking tab to see the new ENI.

Demonstrate Network Failover:

  • Detach the new ENI from the first instance.
  • Click Actions > Detach (use force detach if necessary).
  • Attach the ENI to the second instance.
  • Check the second instance’s Networking tab to see the new ENI.

Terminate Instances and Observe ENIs:

  • Terminate both instances.
  • Check Network Interfaces.
  • The ENIs created with the instances will be deleted.
  • The manually created ENI will remain.

Key Points:

  • ENI: Virtual network card providing network connectivity.
  • Attributes: Primary/secondary private IPv4, Elastic IP, security groups, MAC address.
  • Flexibility: Attach/detach ENIs between instances for failover.
  • High Availability: Move ENIs between instances for minimal downtime.
  • Persistence: Manually created ENIs persist after instance termination.

This hands-on practice covers creating, attaching, detaching, and reattaching ENIs, as well as understanding their persistence and usage for failover and advanced networking setups.

If you found this guide helpful then do click on 👏 the button.

Follow for more Learning like this 😊

If there’s a specific topic you’re curious about, feel free to drop a personal note or comment. I’m here to help you explore whatever interests you!

Thanks for spending your valuable time learning to enhance your knowledge!

--

--

Nidhi Ashtikar
Nidhi Ashtikar

Written by Nidhi Ashtikar

Experienced AWS DevOps professional with a passion for writing insightful articles.

No responses yet