AWS Elastic Network Interface

I was a bit confused with the term of “ENI”, after some research and testing, I finally make myself clear with it.

Two Scenarios:

EC2 instance with multiple network adapters ( for example, eth0 and eth1)

The use cases for this setting:

  • Dual-homed instance
  • Create additional management network

EC2 instance with one network adapter but have two or more private IP address

The use cases according to AWS documentation are:

  • Host multiple websites on a single server by using multiple SSL certificates on a single server and associating each certificate with a specific IP address.
  • Operate network appliances, such as firewalls or load balancers, that have multiple private IP addresses for each network interface.
  • Redirect internal traffic to a standby instance in case your instance fails, by reassigning the secondary private IP address to the standby instance.

Best Practices for Configuring Network Interfaces (copied from AWS)

  • You can attach a network interface to an instance when it’s running (hot attach), when it’s stopped (warm attach), or when the instance is being launched (cold attach).
  • You can detach secondary (ethN) network interfaces when the instance is running or stopped. However, you can’t detach the primary (eth0) interface.
  • You can attach a network interface in one subnet to an instance in another subnet in the same VPC; however, both the network interface and the instance must reside in the same Availability Zone.
  • When launching an instance from the CLI or API, you can specify the network interfaces to attach to the instance for both the primary (eth0) and additional network interfaces.
  • Launching an Amazon Linux or Windows Server instance with multiple network interfaces automatically configures interfaces, private IPv4 addresses, and route tables on the operating system of the instance.
  • A warm or hot attach of an additional network interface may require you to manually bring up the second interface, configure the private IPv4 address, and modify the route table accordingly. Instances running Amazon Linux or Windows Server automatically recognize the warm or hot attach and configure themselves.
  • Attaching another network interface to an instance (for example, a NIC teaming configuration) cannot be used as a method to increase or double the network bandwidth to or from the dual-homed instance.
  • If you attach two or more network interfaces from the same subnet to an instance, you may encounter networking issues such as asymmetric routing. If possible, use a secondary private IPv4 address on the primary network interface instead. For more information, see Assigning a Secondary Private IPv4 Address. If you need to use multiple network interfaces, you must configure the network interfaces to use static routing. For more information, see Configure a Secondary Elastic Network Interface.

Simple AWS CLIs

Before starting to use AWS CLIs, you have to install aws cli packages and configure the credentials. Details, install package can be found here and credential configuration can be found here.

  1. Provision ec2 instance

    aws ec2 run-instances  –subnet-id=”subnet-be426cc8″ –image-id=”ami-9a3322f9″ –instance-type “t2.micro”

  2. Terminate ec2 instance

    aws ec2 terminate-instances –instance-id=”i-04d1633a4097dccc0″