Elastic network interfaces
ENIs are the virtual network cards of EC2 instances; what they carry, and moving them between instances for failover.
What it is
An elastic network interface (ENI) is a virtual network card in a VPC. Every instance has at least one, and the instance's IP addresses and security groups actually belong to its ENIs.
An ENI can have:
- a primary private IPv4 address, and one or more secondary private IPv4 addresses;
- one Elastic IP for each private IPv4 address;
- one public IPv4 address;
- IPv6 addresses;
- one or more security groups;
- a MAC address.
An ENI lives in one subnet, so it's bound to one Availability Zone. ENIs have no extra charge.
How it works
- The primary ENI (
eth0) is created with the instance and can't be detached. - Secondary ENIs can be created on their own and attach or detach them while the instance is running. The number of ENIs an instance can have depends on its type.
- An ENI keeps its IPs, security groups and MAC address when it moves. Moving it to another instance moves the traffic too.
Failover with an ENI
- Instance A has its primary ENI
eth0and a secondary ENIeth1with the private IP10.0.0.42and an Elastic IP. Clients connect to that IP. - Instance A fails.
- An admin (or a script) detaches
eth1from A and attach it to standby instance B in the same AZ. - Clients keep using the same IP, now answered by B. No DNS change is needed.
The same trick lets a software licence tied to a MAC address move to a new instance.
Other uses
- Two networks on one instance: a management ENI in an admin subnet and a public ENI in a web subnet, each with its own security groups.
- Network appliances: firewalls and load balancers with several interfaces.
- AWS services use ENIs too: Lambda functions in a VPC, RDS databases and VPC endpoints all appear as ENIs in the VPC's subnets. If an ENI's description says it's requester-managed, an AWS service created it.
Beyond the exam: why ENIs matter for troubleshooting
When a subnet or security group can't be deleted, the cause is usually an ENI still using it, often one created by a service such as Lambda or a VPC endpoint. EC2 → Network Interfaces, filtered by subnet or security group, shows who owns it. VPC Flow Logs, covered in the VPC group, are also captured per ENI.
Exam tips
- "Move a private IP (or MAC address) to a standby instance for failover" → detach and attach a secondary ENI.
- "Instance in two subnets / dual-homed" → attach a second ENI from the other subnet (same AZ).
- ENIs are tied to one AZ. Failover by moving an ENI only works within that AZ.
Common traps
- "Move the ENI to an instance in another AZ." An ENI can only attach to instances in its own AZ.
- "Detach the primary ENI." Only secondary ENIs can be detached.
Hands-on lab: move an ENI between instances
Goal: create an ENI, attach it to one instance, then move it to another and see its IP follow.
Costs money
Two t3.micro instances with public IPs, about $0.04 an hour together. The ENI itself is free.
Launch two instances in the same AZ
Launch two t3.micro instances, saa-eni-a and saa-eni-b, with Amazon Linux 2023 and tag Project=saa-lab. In Network settings → Edit, pick the same subnet for both (for example the one in us-east-1a).
Create an ENI
Open Network & Security → Network Interfaces → Create network interface: description saa-eni, the same subnet, IPv4 auto-assign, security group default. Note its private IP.
Attach it to A
Select the ENI, Actions → Attach, choose saa-eni-a. On the instance's Networking tab, it now has two private IPs.
Move it to B
Actions → Detach (tick force if needed), then Actions → Attach to saa-eni-b. The same private IP now belongs to saa-eni-b.
Expected result: the ENI's IP address moves from one instance to the other, and the primary interfaces never change.
Clean up: terminate both instances, then delete the ENI in Network Interfaces (it's kept when the instance is terminated, because you created it separately).