Explained: AWS ENIs (Elastic Network Interfaces)

Codelooru mythos

Your production database server starts throwing errors at 2 a.m. The on-call engineer spins up a replacement instance, and now the scramble begins: update the DNS record, wait for the TTL to expire, reconfigure the firewall rules that were pinned to the old private IP, and hope every downstream service notices the change. Twenty minutes of downtime, most of it spent chasing a network identity that was welded to a machine that no longer exists.

That coupling is the problem. The IP address, the MAC address, the security rules, all of it lived on the instance. Kill the instance and you lose the identity with it.

AWS solves this by pulling the network identity off the instance and turning it into a thing you can pick up and move. That thing is the Elastic Network Interface.


What an ENI actually is

An ENI is a virtual network card that lives in your VPC, independent of any single instance. You can create, attach, detach, and manage ENIs independently of EC2 instances. Think of it as the network identity of a machine, packaged as a resource you can attach to one instance today and a different instance tomorrow.

It is not a piece of hardware and not a feature of the instance. It is a first-class object in the VPC with its own lifecycle, its own console page, and its own ID in the form eni-1234567890abcdef0.

Every ENI carries a bundle of attributes. The important ones are a primary private IPv4 address from the subnet range, optional secondary private IPv4 addresses, optional IPv6 addresses, one or more associated Elastic IPs, a unique MAC address, and one or more security groups.

The detail that makes ENIs useful is what happens to that bundle when you move it. The primary private IP, secondary private IPs, and any associated Elastic IP addresses remain with the network interface when it is detached from one instance and attached to another. The identity travels with the interface, not with the machine.

An ENI bundles network identity into one movable object EC2 Instance compute only CPU / memory disk / OS attach Elastic Network Interface Primary private IPv4 Secondary private IPv4s Elastic IP associations MAC address Security groups The instance provides compute; the ENI provides identity. They are separate resources.

Primary versus secondary interfaces

Every EC2 instance is born with one ENI already attached. This is the primary network interface, sometimes shown inside the OS as eth0. You cannot detach a primary network interface from an instance. It is created when the instance launches and deleted when the instance terminates. Its life is the instance's life.

The interesting work happens with secondary network interfaces. These you create yourself, attach to an instance, and detach at will. You can detach a secondary network interface from one instance and attach it to another instance, while the primary interface stays put. A secondary ENI you created by hand persists even after the instance it was attached to is gone, which is exactly what you want for an identity meant to outlive any single machine.

There are three moments at which you can attach an interface. You can attach a network interface when the instance is running (a hot attach), when it is stopped (a warm attach), or while the instance is being launched (a cold attach). Hot attach is the one that enables zero-restart failover, and it is the reason ENIs matter for high availability.

One instance, multiple interfaces EC2 Instance Primary ENI (eth0) Created with the instance Cannot be detached Dies with the instance Secondary ENI (eth1+) Created by you Detach and reattach freely Outlives the instance Solid line: permanent. Dashed line: movable.

The constraints that shape every design

Two limits govern how you use ENIs, and both come from physical reality rather than arbitrary policy.

The first is locality. You can only attach a network interface to an instance in the same Availability Zone as the interface. An ENI is anchored to its subnet, and a subnet lives in exactly one AZ. You also can't move an ENI to another subnet after it is created. Failover with ENIs is therefore an in-AZ trick; surviving the loss of an entire zone requires a different mechanism.

The second is capacity. You can attach additional secondary interfaces up to a limit that depends on the instance type. A small instance might allow two interfaces; a large one allows many more. The number of IP addresses you can pack onto each interface scales the same way. If you need lots of addresses, a bigger instance buys you more headroom.

One persistent misconception deserves a direct correction. Attaching a second ENI does not give you more network bandwidth. Adding another interface to a dual-homed instance is not a way to increase or double the bandwidth to or from that instance. Bandwidth is a property of the instance, not the count of interfaces hanging off it.


The failover pattern

This is where everything above pays off. Picture a primary instance running a service, with a secondary ENI attached that holds the IP address clients actually connect to. A standby instance sits ready in the same AZ, pre-configured for the same role.

When the primary fails, you detach the secondary ENI and hot-attach it to the standby. Because the interface keeps its private IP, its Elastic IP, and its MAC address, traffic begins flowing to the standby as soon as the interface is attached. No DNS change, no TTL wait, no firewall edits. Clients never learn that the machine behind the address changed.

The same idea runs in reverse for outbound identity. If a partner has whitelisted your Elastic IP, that IP lives on an ENI, so the instance presenting that identity to the outside world can be replaced without anyone updating an allowlist.

Failover: the ENI moves, the identity stays Client Secondary ENI holds the service IP Primary instance FAILED Standby instance same AZ, same role connects was here detach + hot attach The IP, Elastic IP, and MAC address follow the interface to the standby. The client never sees the change.

Where else you meet ENIs

Failover is the headline use, but ENIs show up across AWS in ways that are worth recognizing.

Dual-homed instances. Attach two interfaces in different subnets and an instance can sit on both at once. A common split is one interface for management traffic and another for public-facing traffic, each with its own security group enforcing different rules. This is the standard shape for security appliances, NAT instances, and proxies.

Multiple IPs on one box. Secondary private IPs let you host several applications on a single instance, each with its own address, without a separate interface for each.

Service-managed interfaces. Many AWS services plant an ENI in your VPC to reach your resources. When you look at a network interface attached to a load balancer, a Lambda function, or a NAT gateway, you cannot detach it directly, because the owning service manages it. If you have ever wondered why a Lambda function in a VPC consumes IP addresses from your subnet, this is the answer: it places ENIs there.

One trap to avoid: if you attach multiple interfaces from the same subnet to one instance, you can hit asymmetric routing problems, so adding a secondary private IP to the existing interface is often the cleaner choice. Multiple interfaces are for spanning subnets, not for piling addresses onto one.


Summary

The single idea behind the ENI is decoupling. An instance is compute; an interface is identity; AWS lets you manage the two separately. Once that split exists, a whole class of operational problems dissolves. Failover stops meaning "reconfigure the network" and starts meaning "move one object." Whitelisted IPs survive instance replacement. Management and data traffic land on separate interfaces with separate rules.

The constraints are the boundaries of the idea, not exceptions to it. ENIs stay within one Availability Zone because they are anchored to a subnet, and they do not multiply bandwidth because bandwidth was never theirs to give. Understand the interface as a movable bundle of identity, respect those two limits, and most AWS networking patterns you encounter will make immediate sense.


Part of the Explained series — concepts in tech, clearly.



×