Build a lab demonstrating AWS Elastic Network Interfaces (ENIs) and learn:
- What an ENI is
- How multiple network interfaces work on an EC2 instance
- Moving IP addresses between instances
- High availability and failover scenarios
- Real-world networking use cases
An ENI is a virtual network card that can be attached to an EC2 instance.
Think of it as:
Physical Server
|
+---- Network Card 1
+---- Network Card 2
In AWS:
EC2 Instance
|
+---- ENI-1
+---- ENI-2
Each ENI can have:
- Private IP addresses
- Public IP addresses
- Security Groups
- MAC Address
- Elastic IPs
Normally:
EC2 Instance
|
v
Private IP
If the server fails:
Private IP Lost
Applications may become unreachable.
Using ENI:
ENI
|
+---- Private IP
+---- Security Groups
Move ENI to another server:
EC2-A (Failed)
|
X
Detach ENI
Attach ENI
EC2-B
Application becomes available again.
Application
|
v
Private IP
|
v
ENI
|
v
EC2 Instance
The network identity belongs to the ENI, not the server.
Primary Server
|
v
ENI
Failover:
Primary Down
|
v
Move ENI
|
v
Standby Server
Examples:
- Fortinet
- Palo Alto
- Check Point
Often use:
ENI 1 → Public Network
ENI 2 → Internal Network
Web Traffic
|
v
ENI-1
Management Traffic
|
v
ENI-2
VPC
|
-----------------
| |
v v
EC2-A EC2-B
|
v
Secondary ENI
Services Used:
- VPC
- EC2
- ENI
- Security Groups
Create:
Primary Server
Standby Server
Move an ENI between them.
Demonstrate:
Application IP remains same
even though server changes.
Launch:
EC2-A
EC2-B
Example:
Amazon Linux 2023
t2.micro
Same subnet.
Navigate:
EC2
→ Network Interfaces
→ Create Network Interface
Configuration:
Subnet:
Same subnet as EC2
Private IP:
10.0.1.100
Security Group:
Allow SSH
Allow HTTP
Attach to:
EC2-A
Verify:
ip addrOutput:
eth0
10.0.1.25
eth1
10.0.1.100
Install nginx:
sudo dnf install nginx -y
sudo systemctl enable nginx
sudo systemctl start nginxCreate page:
echo "Primary Server" | sudo tee /usr/share/nginx/html/index.htmlOpen:
http://10.0.1.100
Response:
Primary Server
Notice:
Traffic uses ENI IP
Stop nginx:
sudo systemctl stop nginxor stop instance.
Navigate:
EC2
→ Network Interfaces
Detach ENI from:
EC2-A
Attach same ENI:
10.0.1.100
to:
EC2-B
Install nginx:
echo "Standby Server" | sudo tee /usr/share/nginx/html/index.htmlStart:
sudo systemctl start nginxOpen:
http://10.0.1.100
Response:
Standby Server
Important:
IP Address Never Changed
Only server changed.
Each ENI contains:
Private IP
Security Groups
MAC Address
Elastic IP Mapping
These move together.
| Feature | Primary ENI | Secondary ENI |
|---|---|---|
| Can Detach | No | Yes |
| Created at Launch | Yes | No |
| Move Between EC2 | No | Yes |
| Common Usage | Default Networking | HA & Advanced Networking |
Example:
ENI-1
|
+--- SSH Only
ENI-2
|
+--- HTTP Only
Different interfaces can have different security policies.
EC2 Instance
|
+---- ENI-1
| |
| +--- Public Traffic
|
+---- ENI-2
|
+--- Database Traffic
Common in enterprise environments.
Internet
|
v
ENI-1
|
Firewall
|
ENI-2
|
Internal Network
Used by:
- Fortinet
- Palo Alto
- Check Point
virtual appliances on AWS.
AWS CNI uses ENIs extensively.
Worker Node
|
+---- ENI
|
+---- Pod IPs
Each ENI provides IP addresses for pods.
This is why Kubernetes on AWS can assign VPC IPs directly to pods.
Attach:
Elastic IP
|
v
ENI
Move ENI:
EC2-A → EC2-B
Public IP moves automatically.
Application
|
+---- ENI-1 (Users)
+---- ENI-2 (Management)
+---- ENI-3 (Database)
Traffic separation.
Primary DB
|
v
ENI
Move ENI:
Primary
|
Fail
|
Standby
Application continues using same IP.
Answer: An Elastic Network Interface is a virtual network card that can be attached to an EC2 instance and contains IP addresses, security groups, and networking configuration.
Answer: Yes. Secondary ENIs can be detached from one instance and attached to another within the same Availability Zone.
Answer: They allow network identity (IP address and security settings) to move independently of compute resources.
Answer:
Primary ENI:
- Created automatically
- Cannot be detached
Secondary ENI:
- Created manually
- Can be detached and moved
Answer: The AWS VPC CNI plugin allocates pod IP addresses from ENIs attached to worker nodes.
Answer: Yes. Security groups are associated directly with ENIs and move with the interface.
After completing this lab, students should understand:
- What an Elastic Network Interface is.
- How AWS networking is abstracted through ENIs.
- Primary vs Secondary ENIs.
- Failover using ENIs.
- Security groups on ENIs.
- Multi-homed server architectures.
- Firewall appliance networking.
- Elastic IP association with ENIs.
- Kubernetes AWS CNI networking concepts.
- Real-world AWS networking and high-availability use cases.